Like a lot of things in the tech world these days, it all started with a short question on Reddit:
Keyboard shortcut to search programs in overview like Gnome?
byu/AveryFreeman inkde
Teal;Deer:
I found out the meta-only modifier is one thing that needed to be set in
(my synoposis in the subred)$HOME/.config/kwinrc
, but also theExposeAll=Meta
config in$HOME/.config/kglobalshortcutsrc
– so there’s two places where it needs to be set. Also, you can add/KWin reconfigure
to the end and it should start working immediately (reloads kwin config). But hey, thanks so much for pointing me in the right direction!
The biggest impediment to getting the Gnome-like super
key behavior in KDE is getting KDE to interpret a single keypress as a keyboard shortcut. If you look at it critically, you can see there’s a lot going on in that single keypress in Gnome: In Gnome, a single keypress gives you both the open windows overview, and a search bar, and even has additional menus accessible from repeating the action (double-pressing super
).
KDE isn’t really able to allow single-keypress shortcuts by default, but there’s a spot they’ve carved out where users can add the behavior if they really want to (I get the sense it’s caveat emptor). I’ve never been particularly interested in sticking to pre-defined conventions, so I set out to find out how we could make super
behave like it does in Gnome. It couldn’t be that hard, right?
I wanted to know what was going on under the hood, so I did some digging. The most complete reference on the KDE configuration files I’ve found so far is here: https://userbase.kde.org/KDE_System_Administration/Configuration_Files
There’s a whole bunch of really great examples here: https://userbase.kde.org/Plasma/Tips
There’s some man files that are also helpful here (I don’t think this particular spec has changed from KDE 5 to 6):
https://linuxcommandlibrary.com/man/kreadconfig5
https://linuxcommandlibrary.com/man/kwriteconfig5
I found the shortcuts in KDE6 are located in a file named /home/$USER/.config/kglobalshortcutsrc
. They’re grouped by category with the names in brackets, like [ActivityManager]
, [kmix]
, etc.
So, related to my question, when I opened this file, under [kwin]
I found this:
# $HOME/.config/kglobalshortcutsrc
[kwin]
Activate Window Demanding Attention=Meta+Ctrl+A,Meta+Ctrl+A,Activate Window Demanding Attention
Cycle Overview=Meta+Tab,none,Cycle through Overview and Grid View
Cycle Overview Opposite=none,none,Cycle through Grid View and Overview
. . .
ExposeAll=Meta,Ctrl+F10\tLaunch (C),Toggle Present Windows (All desktops)
. . .
And when I ran the following:
kreadconfig6 --file kglobalshortcutsrc --group kwin --key ExposeAll
I get this response in my terminal:
. . .
Meta,Ctrl+F10 Launch (C),Toggle Present Windows (All desktops)
So in reference to the kreadconfig6
syntax, the key
is the kwin
action named ExposeAll
. The group should be the category of actions, [kwin]
. The harder part is keeping the description in there when writing from the command line, because it’s tab-separated, \t
to the right of the same line. But anyway, I am assuming it would be:
kwriteconfig6 --file kglobalshortcutsrc --group kwin --key ExposeAll Meta"
Or if you needed the descriptor to be in the same line as the value (like in the text file), it would be:
kwriteconfig6 --file kglobalshortcutsrc --group kwin --key ExposeAll Meta\tLaunch (C),Toggle Present Windows (All desktops)"
I’m not sure if kwriteconfig6
can sort out the tab-separated sections on its own, but I imagine it probably can. I have shied away from editing these config files in a text editor just in case there’s some specificity they have regarding tab and whitespace I might mess up, but I imagine it could be one option – if you try it, be sure to use a tabspace
v whitespace
identifier plugin for vim
Thankfully normal people can add this behavior from the GUI under Ksettings -> Shortcuts -> Kwin
, too – so that’s reassuring!
A bigger issue might be specifying that you can use only a modifier key as a shortcut (e.g. meta
, alt
, shift
, etc.) which is what the answer to my reddit question addressed (although I don’t think they were aware, exactly).
Therefore, settings need to be created or modified in two separate places, once for the key behavior, ExposeAll
(previous example), and another for allowing the key to behave like a shortcut. As far as I can tell, allowing Meta
on its own to ‘be’ a shortcut does need to be invoked at the command line. Here’s the process:
Meta
(the keypress) is the key
value in the pair, analogous to the example with ExposeAll
. It will end up in the config file for kwin
:
# $HOME/.config/kwinrc
[ModifierOnlyShortcuts]
Meta=org.kde.kglobalaccel,/component/kwin,org.kde.kglobalaccel.Component,invokeShortcut,Overview
Coincidentally, there the syntax to add it is provided at the end of the kwriteconfig5
man file I linked above. At the very end, it gives the example:
kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.kglobalaccel,/component/krunner_desktop,org.kde.kglobalaccel.Component,invokeShortcut,_launch"
… which is for launching krunner
if you hit meta
by itself.
If you’d want the config to be reloaded (to start working immediately) you can add /KWin reconfigure
to the end.
So I’m assuming if you already have the ExposeAll
behavior in your kglobalshortcutsrc
and you run the above argument, it should combine krunner
with ExposeAll
under the Meta
keypress, which is extremely Gnome-like behavior (and pretty exciting!)
TBH I was trying all sorts of stuff when I was doing this and am not sure the exact point at which I got the desired behavior, it might require re-logging in or something like that, too. But these are the two elements you’d need in which to get the Gnome-like action from smashing your Meta
key.
One last thing – you may have noticed there’s a more conventional keyboard shortcut Ctrl+F10
for ExposeAll
in $HOME/.config/kglobalshortcutsrc
– one that actually combines two keys, like normal (gee, seems quaint!)
[kwin]
. . .
ExposeAll=Meta,Ctrl+F10\tLaunch (C),Toggle Present Windows (All desktops)
. . .
That’s because the userbase.kde.org
site I linked at the top says a single-key shortcut (Meta
) might not work if there isn’t a key combination shortcut also configured for the same action (Ctrl+F10
)
Lastly, I threw together a little one-liner that dumps all the configs into a single text file for analyzing. It makes them a little easier to sift and not have to open each one individually. Just run it from the $HOME/.
folder:
for i in $(ls -a1 .config/k*); do echo "File: $(pwd)/$i"; echo ' '; cat $i; echo ' '; echo '--- end ---'; echo ' '; done > ./kde-config-files.txt
I’ll probably put all my KDE6 configs in a git repo one of these days, but for now, I’m off to study ORM development with Python and SQL… Cheers!
2 responses to “Bring Single-Meta-Keypress Overview Behavior to KDE6 (just like Gnome!) – and a bit on KDE configuration files…”
Hey! Thank you for this article and your work on Reddit where I found links for this solution. Today Plasma updated to 6.1 and the rebooting system started to rewrite $HOME/.config/kglobalshortcutsrc. But it provides the possibility to set a single Meta for shortcut by GUI.
The new notation in the config looks like this:
ExposeAll=Meta\tCtrl+F10\tLaunch (C),Ctrl+F10\tLaunch (C),Toggle Present Windows (All desktops)
I don’t know whether we need to fix $HOME/.config/kwinrc, but after reboot, my changes added to the end of the file were moved to upper.
Nice, I’m glad they’re making it easier for people. Gnome really started a trend – once I started using that sweet, sweet Meta key for a while, I could never go back. I’m a little confused, though, it looks like the behavior for `Meta` is different than `ctrl-f10` (?) If I’m reading it correctly, it looks like only `ctrl-f10` will `Toggle Present Windows (All desktops)`. If it’s not giving you the window overview with the `Meta` key by itself, I’ll bet you could delete the portion between the two tabstops (`\t`)