Skip to main content

Nico's blog

Task Manager Improvements in Plasma 5.24

In my last post I talked about why knowing the desktop file for a window is important for the task manager. I promised to talk about some cool stuff we did there in Plasma 5.24, so here we are.

While hacking on the task manager code I noticed that we show a “Open new instance” action in the context menu of every task manager entry, even for those where it doesn’t make sense. A lot of apps are inherently single-window or single-instace, i.e. launching the app a second time will not open a second window but rather focus the existing one. Also, not all windows actually belong to a user-facing or user-launchable application. For example the network integration might ask you for the WiFi password, but you can’t open a new window for that from the task manager. Another kind of app where this actions doesn’t make sense is helper applications like the wizard for connecting to a new bluetooth device.

After some initial refactoring the first thing I did was hide the action for apps that have NoDisplay=true in their desktop file. These usually correspond to the aforementioned background services and helper apps. With that in the situation was improved for a great deal of windows. However, the case of single-window application was still unsolved. After reading some older, related discussion, I found that our friends at GNOME had solved this problem for them already. Their equivalent part of the code, amongst other heuristics, reads the X-GNOME-SingleWindow key from the application’s desktop file. So I did the obvious thing and added reading X-GNOME-SingleWindow to Plasma’s task manager code. We also added that key to a bunch of relevant KDE apps. While this was a pragmatic and working solution, relying on a X-GNOME- key for what we want to be cross-desktop behavior is not ideal. It’s time for standardization!

Nate Graham (you may have heard of him) proposed to add the existing key minus the X-GNOME- prefix to the desktop entry spec. After a bit of discussion about names and semantics people settled on SingleMainWindow as the new name. Implementations for Plasma and GNOME soon followed. What’s missing is adding it for all the apps out there. Besides KDE apps I already did that for qBittorrent, Nextcloud, and Yubico Authenticator. This is an excellent way to contribute to your favorite open source app!

But wait, there is more. Some apps define their own “Open new window” action in their desktop file. To avoid having two redundant actions Plasma now hides its own action when there is already a semantically similar one.

Happy task managing!

© Nicolas Fella, 2024 MastodonNicolas Fella
Powered by Hugo, theme Anubis.