Forum Discussion
How to stop the konsole being minimized on Windows 10?
I want to make it so that when the WIN-D-D key is pressed, all windows are minimized except for the console (as mentioned above). In this way, if I want to quickly open the console, I just need to press Win-D once, use it, and then press Win-D again to restore all windows to their original state.
Do I need to write a kwin script? If so, how should I proceed?
1 Reply
- seunaiconsulting26Tin Contributor
Yes, you'll need a KWin script for this. The built-in Meta+D ("Show Desktop") toggles minimize-all and restore-all, but it has no way to exclude a window — so to keep your console visible you have to script the minimize/restore logic yourself, with a small bit of state so the second press restores only what the first press hid.
The approach is straightforward. First, free up the shortcut: Meta+D is bound by default to "Peek at Desktop / Minimize all windows," so go to System Settings → Shortcuts → KWin and clear it, otherwise your script won't be able to claim the same key.
Then the script does this on each keypress. It keeps a flag for whether it's currently in "desktop" mode and a list of the windows it minimized. On the first press, it walks the window list, skips anything that isn't a normal window (so panels and docks are left alone), skips windows that were already minimized, and skips your console — then minimizes everything else, remembering each one in the list. On the second press, it simply un-minimizes every window in that saved list and clears it. That way it restores exactly the original state, and won't disturb windows you minimized by hand in between.
A few specifics that matter for it to actually work:
The console is identified by its window class, which is the reliable matcher. Run xprop WM_CLASS in a terminal and click your console to get the exact string — it's konsole for Konsole, but kitty, alacritty, yakuake and so on each differ. Match the window's resourceClass against that string. Note that drop-down terminals like Yakuake often aren't classed as normal windows, so the "skip non-normal windows" step may already exclude them.
The scripting API differs by Plasma version. On Plasma 6 you get the windows via workspace.windowList(); on Plasma 5 it's workspace.clientList(). The properties you read on each window — minimized, resourceClass, normalWindow — are the same across both. You register the key with registerShortcut, passing a name, a description, the key sequence ("Meta+D"), and your callback function.
For installation, a KWin script is just a folder with a metadata.json (declaring the name, ID, the JavaScript API, and the path to your main script) and the script itself under contents/code/. Drop the folder in ~/.local/share/kwin/scripts/, install it with kpackagetool6 --type KWin/Script -i . (use kpackagetool5 on Plasma 5), then enable it under System Settings → Window Management → KWin Scripts. If it doesn't take effect, run qdbus6 org.kde.KWin /KWin reconfigure or log out and back in.
One tip while developing: use the Plasma scripting console (Alt+F2, then type wm console) to paste and test your logic live before packaging it — it saves the install/reload cycle each time you tweak something.