Dark mode improvements in Plasma
Dark mode has been available in Plasma for quite a while now but the next release explores new areas where it can be taken one step further, beginning from some behind the scenes infrastructure to more user facing features such as dynamic wallpapers and automatic day/night global theme switching.
My journey to improving dark mode capabilities started at the recent Plasma Sprint. A while ago, I developed a wallpaper plugin that’s capable of synchronizing images to the position of the Sun, which I wanted to upstream but one of the biggest issues was the sheer size of the project. It supports a bunch of modes, it requires special tooling, and the wallpaper format is too cumbersome for upstream (although it’s amazing for 5K or 8K images!). So, I decided to make a pitch for adding one of the modes available in that plugin to other Plasma developers, which should be very easy to integrate with the existing infrastructure in Plasma. The idea was well-received and it led to a discussion about other related things, like better integration of geolocation services in Plasma, etc.

Day/night wallpapers
Some wallpaper packages can contain light and dark images. Currently, the light image will be used with a light color scheme, and the dark image will be used with a dark color scheme. The main idea behind the new day/night dynamic wallpapers was to exploit this design of the wallpaper packages: switch between light and dark images depending on the elevation of the Sun rather than the color scheme.

The plasma5-wallpapers-dynamic served as the basis for the new dynamic wallpaper mode in Plasma. It works exactly like we want. If geolocation data is available, use it to compute the position of the Sun. The daylight duration varies depending on your location throughout the year; by taking the geolocation into account, the dynamic wallpapers can closely match the dark/light cycle. If the geolocation is unknown, fall back to some pre-configured morning and evening times.
From functional point of view, it doesn’t have any purpose, but it’s a lovely touch that helps you to personalize your computer.
While on this, we also looked into optimizing the wallpaper configuration dialog. Specifically, fixing GridView
in QtQuick so it is possible to reuse wallpaper preview items for smoother scrolling and re-working the wallpaper preview generation process for better performance and to make it less error prone.
How to create a day/night wallpaper
A day/night wallpaper is a regular wallpaper package but with light and dark images, Plasma does the rest to figure out what images should be displayed.
For example, imagine that you want to create a wallpaper with a lake. Then the wallpaper would look something like this
Lake/
├── contents
│ ├── images
│ │ ├── 1080x1920.png
│ │ └── 5120x2880.png
│ └── images_dark
│ ├── 1080x1920.png
│ └── 5120x2880.png
└── metadata.json
The Lake
folder contains two things: a contents
folder with images and a metadata.json
file. The metadata.json
file provides extra information about the wallpaper, e.g. the author, etc.
{
"KPlugin": {
"Authors": [
{
"Email": "foobar@example.com",
"Name": "Name of the author"
}
],
"Id": "Next",
"License": "CC-BY-SA-4.0",
"Name": "Lake"
},
"X-KDE-CrossFade": true
}
The Id
specifies the unique id of the wallpaper, the Name
specifies the human readable name of the wallpaper. The metadata may also contain an X-KDE-CrossFade
key, this is used to enable or disable long cross-fade. For example, if the transition from day to night lasts 30 minutes, then Plasma will slowly cross-fade from the light to the dark image for 30 minutes. Such a long cross-fade transition can be undesired if the images are too distinct.
images
and images_dark
folders contain light and dark images, respectively. Note that image file names must match the image resolution, i.e. 5120x2880.png
instead of light.png
, etc.
The wallpaper should be installed in /usr/share/wallpapers
or ~/.local/share/wallpapers
.
knighttime(d)
In addition to day/night wallpapers, it would also be nice if more things could be more dynamic. For example, switching the global theme at night. However, this creates a bit of a problem. If you want to configure the times when wallpapers or themes need to be changed, you will need to set settings for every feature individually, which is not great.
To solve that problem, a new desktop component was introduced that orchestrates when morning and evening transitions occurs – KNightTime. It’s a super duper tiny project with a client library and a daemon (knighttimed
) that provides the schedule for day/night cycle transitions.
Since all features that synchronize to the day/night cycle subscribe to KNightTime, you only need to configure it to use specific morning and evening times. Night Light, day/night wallpapers and so on will be all synchronized.

knighttimed
runs in background and it is started on demand, so in most cases, you don’t even need to worry about its existence.
Day/night themes
Besides the wallpaper, one can also switch between light and dark global themes depending on time of day.
Perhaps the hardest part about this was figuring out how to retrofit our system settings to accommodate for this new mode rather than actually implementing the logic that changes the active theme. Many thanks to Felix Ernst and Nate Graham for providing mock-ups and feedback about the UI.


It is worth noting that Plasma will switch between the themes only if the computer has been idle for 5 seconds. The main reason behind this is to avoid interruptions while actively using the computer. In case you don’t like it, you can turn it off in system settings or increase the default idle interval if you think it’s too low for your needs.
With the automatic mode, the global theme switching code is going to be stress-tested quite a bit, so we’ve also started (and continue) looking into various paper cut issues regarding theme switching, e.g. some buttons not adapting to the new color scheme correctly, etc.
Future improvements
There are other things that can be synchronized to the day-night cycle, for example screen brightness. Although, there is nothing clear on the radar yet.
Conclusion
The next release is going to feature a few dark mode improvements. Some are pretty technical, some are very user facing. In either case, I hope that things like this will help to make Plasma users happier and make Plasma stand out more among other desktop environments.