DEV Community

VaiTon
VaiTon

Posted on • Updated on

How to enable auto dark mode (night theme) in KDE Plasma

Disclaimer!

The method described in this post only works if your cron handles delayed jobs (for when your PC is sleeping/powered off and the job should run).

I got different results from different OS so YMMV!

Intro

Auto dark mode is new feature that has been gaining a lot of popularity in these years.

That's because, with its introduction in Android 10 people have begun to appreciate its benefits, including:

  • Can reduce power usage by a significant amount (depending on the deviceโ€™s screen technology).
  • Improves visibility for users with low vision and those who are sensitive to bright light.
  • Makes it easier for anyone to use a device in a low-light environment.

For GNOME, this shell extension exists: Night Theme Switcher.

For KDE Plasma though, unfortunately, the only automatic way I could find to accomplish this is by using this project on github which is not supported on every distro (although recently added to the OBS).

Despite this, for users that do not want to install something from a PPA / User repository / Source code, another solution exists, and it leverages the plasma plasma-apply-colorscheme command.

How To

First, open up a terminal and write

plasma-apply-colorscheme --list-schemes
Enter fullscreen mode Exit fullscreen mode

to see which color scheme you have installed on your system.

(You can always install more using your distro package manager or the Plasma Settings.)

After locating the two color themes that we want to use for the day theme and the night theme, let's open up the user crontab manager with

crontab -e
Enter fullscreen mode Exit fullscreen mode

and let's create two cronjob by using this website, one that will run when we want to switch to the day theme and the other one when we want to switch to the night theme.

The input command will be

plasma-apply-colorscheme <colorscheme>
Enter fullscreen mode Exit fullscreen mode

For me they will be openSUSE from 07:00 till 20:00 and BreezeDark for the rest of the day, so the two cronjobs will be:

0 20 * * * plasma-apply-colorscheme BreezeDark >/dev/null 2>&1
0  7 * * * plasma-apply-colorscheme openSUSE   >/dev/null 2>&1
Enter fullscreen mode Exit fullscreen mode

And that's all! Let's close the crontab (Esc -> :wq -> Enter) and enjoy the automatic switch!

Top comments (0)