KWin’s Window Rules is maybe my most relied-upon functionality within the KDE ecosystem. I set up keyboard shortcuts like Ctrl+Alt+~, Ctrl+Alt+1, Ctrl+Alt+2, … and so on for each of my most-used applications. (~ is for my Terminal, 1 is for Chrome, 2 is for my IDE, 3 for my DB client…)
The expected functionality is that when I press Ctrl+Alt+2, for example, my IDE will come to the foreground.
Whenever I have a fresh install, the first thing I do is create a set of rules representing each of these. This process rarely-to-never works reliably and as-expected and I can’t tell why. I have tried creating rules via the System Settings dialog, and I have tried creating them by right-clicking my window titlebars, choosing More Actions > Configure Special Application Settings.
My Window Rule is configured as:
- Window Class of either “Exact Match” or “Substring Match” (and value, for example, “jetbrains-phpstorm” for my IDE)
- Add “Shortcut” from Arrangement & Access, with value “Force” and key “Ctrl+Alt+2”.
If I click “Apply” I will be able to bring PhpStorm to the front by pressing Ctrl+Alt+2. I configure the rest of my system this way.
The next time I login, The shortcuts I set for “Google Chrome” (Ctrl+Alt+1) always works. PhpStorm almost never works. DBeaver, my Database client, sometimes works.
To get them working again, I go to the System Settings tool and edit, for example, my jetbrains-phpstorm setting, and the easiest thing to do is to change the “Window class” setting from “Substring Match” to “Exact Match” or vice-versa, then click Apply. It will work. I have to do that for whichever applications are not currently working.
I have had versions of this problem for years on every device I use – I think starting with KDE Neon circa ~2017. I switched to Manjaro ~2019 or so and have used it until about a month ago, when I switched my main workstation to EndeavourOS.
When I was using Manjaro, after many rounds of fiddling with the Window Class (Maybe I ended up with a substring of “phpstorm” for example?) I finally got it so that it remembers all my settings out of the gate… But I can’t seem to recreate it in my EndeavourOS install.
If only there was some way for me to debug this, I feel like that would help. My guess is that some applications start up with a different Window name or something that immediately goes away, but it steals the shortcut and the final window doesn’t get it back or something.
Lastly, this is all done in X11. I tried using Wayland and had the same issue – plus some even more weird things. In Wayland, I set up my shortcuts per above (~, 1, 2, 3) and then found that, after adding DBeaver at Ctrl+Alt+3, immediately Ctrl+Alt+~ stopped opening Konsole. Instead it did nothing, and Ctrl+Alt+3 opened Konsole. Bizarre. Further, I couldn’t just edit the Window Shortcuts in Wayland – I had to go to KDE’s System Settings own “Shortcuts” dialog, find the KWin section, and saw that it had created Application Shortcuts for each. (And they were wrong: Ctrl+Alt+3 was assigned to Konsole. And setting it back never worked. I forget how, but I think it said Ctrl+Alt+3 but just ignored it?)
Anyway, I’d be so happy if I could get it so I didn’t have to re-save all my shortcuts when I log in each day.