How do I make Konsole follow system theme?

I use Koi to toggle between Light and Dark themes at a schedule. It works great for all of my apps except Konsole.
I setup a quick profile in Konsole for light theme, sure it works. How do I configure Konsole so that it toggles between Light and Dark theme according to time or the system theme?

You can run Konsole with the --profile <name> argument. This will launch Konsole with a profile loaded.

So set up two profiles, one dark, one light.

Copy /usr/share/applications/org.kde.konsole.desktop to ~/.local/share/applications/ and change the Exec field to launch the profile you want.

Next, you need a script or two that will change that desktop file whenever you change from light to dark theme and vice-versa. The simplest way is to have two more desktop files (one with the light profile in the Exec field, one with the dark one) and just copy and overwrite the .desktop file in ~/.local/share/applications/.

So the script would be something like:

#!/bin/sh

#change from light to dark:
cp -f "~/path/to/dark_konsole.desktop" "~./local/share/applications/org.kde.konsole.desktop"

And a similar one for dark to light.

I’ve never used Koi so I don’t know if you can run this script with it, but if you can’t, you can make a cron job or a soystemd timer to do it for you (at the same time you change the theme with Koi).

This is somewhat working.

So I’m using two cron jobs

# Change Konsole theme at boot depending on time
@reboot cd /home/badland/scripts/konsole/ && ./konsole_theme.sh

# Change konsole theme to dark at 18:00
0 18 * * * cd /home/badland/scripts/konsole/ && ./konsole_dark.sh

However during my testing, I found out that after changing the profile once, changing it again still used the previous file. So I had to add
update-desktop-database ~/.local/share/applications
in my script.

Lastly there’s another thing, a new tab doesn’t follow the profile theme which has been set.
I’ve tried doing the same thing to

[Desktop Entry]
DefaultProfile=profile_name

in
~/.config/konsolerc
but it doesn’t work.

So I guess we need to find a way to change default profile instead of launching with a custom profile.

2 Likes

Is the setting “run all…in a single window” unchecked in konsole?

This command should open a new tab in the same profile:
qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_WINDOW newSession

Yup its unchecked.
I tried the command in Konsole but nope it still opens in the default profile that has been set.

So I tried setting the light theme and checked if konsolerc changes. It changed to

[Desktop Entry]
DefaultProfile=light.profile

Just need added to add .profile at the end sheesh.
I also had problem with color scheme not changing to default in dark mode so I had to set it to empty in konsolerc.

[UiSettings]
ColorScheme=

I think its good right now, I’ll see if I have any more problems

For future reference to anyone coming here

Crontab

# Change Konsole theme at boot depending on time
@reboot cd /home/badland/scripts/konsole/ && ./auto.sh

# Change konsole theme to dark at 18:00
0 18 * * * cd /home/badland/scripts/konsole/ && ./dark.sh

auto.sh

#!/bin/bash

currenttime=$(date +%H:%M)
if [[ "$currenttime" > "07:00" ]] && [[ "$currenttime" < "18:00" ]];   then
  cp -f "/home/badland/scripts/konsole/konsolerc_light" "/home/badland/.config/konsolerc"
elif [[ "$currenttime" > "18:00" ]];  then
  cp -f "/home/badland/scripts/konsole/konsolerc_dark" "/home/badland/.config/konsolerc"
fi

dark.sh

cp -f "/home/badland/scripts/konsole/konsolerc_dark" "/home/badland/.config/konsolerc"
1 Like

I’m not sure, but auto.sh don’t change the Konsole between 00:00 and 06:59 and exact at 18:00

Why not use only if - else?

I usually don’t boot up at that time so I thought not to. But better safe than sorry.
I’ll just change it to else condition, thanks

1 Like