Demo

Let’s be honest, you want to see it work first. 🙃

Animated GIF showing the script do its magic

Introduction

I like it when my desktop changes between light and dark themes based on when the sun sets ☀️. A lot of devices support this functionality, and it’s gorgeous.

I don’t like it when I look at my screen in the evenings, and all the white illuminates the room. Nor do I like it when I have to stare at white letters on a dark background during the daytime. Android authority has a great article on why you may want to avoid it.

For KDE, the functionality of switching between light and dark themes is sadly not native (yet?). But there’s an amazing application called Koi that fills the gap!

Koi

From their GitHub:

Koi is a program designed to provide the KDE Plasma Desktop functionality to automatically switch between light and dark themes. Koi is under semi-active development, and while it is stable enough to use daily, expect bugs. Koi is designed to be used with Plasma, and while some features may function under different desktop environments, they are untested and unlikely to work…

This is what Koi looks like: Screenshot showing koi, left in light mode and right in dark mode

Please refer to their GitHub for installation instructions to install koi on your machine.

The configuration of Koi comes later, once we have prepared the Konsole profiles.

Configure Koi

At this stage, it is nice to configure Koi how you like it. My Koi configuration looks as follows:

Screenshot showing my Koi configuration

This already gives a big hint about the Custom BASH script. You may skip that bit, we will configure it later.

Konsole

In order for colours to work with Konsole, we will need to switch between profiles. This means we need to create two profiles: light and dark.

Creating profiles

Start konsole, and navigate to Settings > Manage Profiles. This may be hidden hunder the hamburger menu as such: Screenshot showing how to navigate to Manage Profiles

From there, create two profiles. One called light and one called dark. Screenshot showing the Manage Profiles dialog

It is important that for the light profile, you select a light colourscheme, and for the dark profile, you select a dark colourscheme.

Screenshot showing example colourscheme configuration

I personally like flexoki-light for my light scheme, and use the default breeze for the dark colourscheme.

Once these profiles have been created, it’s time to create a script that can switch all active konsole sessions to this new colourscheme, and also set it as the new default. This way, all existing tabs and windows will switch from dark to light and light to dark, as well as newly created sessions.

Creating a script that can change the profiles

Next up, we will create the script to switch between sessions. I have placed this script under ~/.local/bin/konsole-colour-switcher.sh. But you are obviously free to place it wherever you want, but adjust your Koi configuration accordingly. 😉

#!/usr/bin/env bash

# Written by Jeffrey Bouter on 2025-04-24
# Licensed under the AGPL

usage() {
  echo "$0 light|dark"
  exit 1
}

SERVICE=$(qdbus6 | awk '/org.kde.konsole/ { print $1 }')
SESSIONS=$(qdbus6 "$SERVICE" | awk '/Sessions\// { print $1 }')
WINDOWS=$(qdbus6 "$SERVICE" | awk '/Windows\// { print $1 }')

case $1 in
  light) THEME=light ;;
  dark) THEME=dark ;;
  *) usage;;
esac

# Set the new default theme
kwriteconfig6 --file ~/.config/konsolerc --group "Desktop Entry" --key "DefaultProfile" "${THEME}.profile"

# Update all existing sessions
for session in $SESSIONS; do
  qdbus6 "$SERVICE" "$session" org.kde.konsole.Session.setProfile "$THEME"
done

# Set the default for all currently opened windows
# as konsole does not re-load konsolerc for opened windows
for window in $WINDOWS; do
    qdbus6 "$SERVICE" "$window" org.kde.konsole.Window.setDefaultProfile "$THEME"
done

Be sure the script has execute rights. If it does not, execute:

chmod 755 ~/.local/bin/konsole-colour-switcher.sh

Adding the script to Koi

Because the above scripts takes arguments (light and dark), it cannot be added straight through the Koi interface. However, it is very easy to add the arguments regardless.

Open up the Koi configuration with your favourite editor. The location is ~/.config/koirc. We will need to modify the [Script] bit of the configuration file and make it looks as follows:

[Script]
dark=/home/jbouter/.local/bin/konsole-colour-switcher.sh dark
enabled=true
light=/home/jbouter/.local/bin/konsole-colour-switcher.sh light

Now restart Koi (it doesn’t load the changes live), and test the functionality! 😄