dec05eba
kiwifarms.net
- Joined
- Jul 27, 2022
My application is probably the first to add support for global hotkeys (shortcut) on wayland (I added it long ago) and I can say that its broken by design. To begin with it's not actually "global hotkeys" as people expect, it's closer to remote actions that you can trigger. For example when you use global shortcuts on kde you can suggest hotkeys that it will use and the user can change them and the application is able to list the shortcuts in its settings. As you would expect it to work.Redditors seem to be getting more & more fed up with Wayland lately. Usually these types of posts have a lot of downdoots from the cultists, rampant accusations of XLibre fascist promotion, "it werks for me" or w/e else, but not this time.
You even have people calling for people to just go back to X11 now:
View attachment 7908030View attachment 7908031
View attachment 7908056View attachment 7908061
![]()
Hyprland on the other hand just ignores the suggested hotkeys. You have to instead run a command manually as the user to list the hotkeys that you are expect to manually bind to keys in your hyprland config file. You have to do this when the application is running. You cant even see which application the hotkey is registered from so you dont know what it exactly does. Hyprland doesn't show the application the hotkeys registered either, so the application cant list which hotkeys do what.
This is what it looks like in hyprland:
How is a user even supposed to know that the application has registered hotkeys when the application cant show them? You have to design a special hyprland specific UI in your application that tells the user to run this command manually and then manually register them.$ hyprctl globalshortcuts
:Record -> Start recording
The global shortcuts api also works differently on different wayland compositors. For example on gnome you are expect to call BindShortcuts on startup, otherwise hotkeys dont work. If you do that on KDE then it will show the hotkey settings (kde settings) everytime you start your application. So to make this work you have to check which wayland compositor you are running and do different behaviors for each one, even though wayland doesn't have a way to know which wayland compositor you are using (you have to guess based on available protocols).
All of these different behaviors are valid interpretations of the global shortcuts specification since it's too vague.
Global shortcuts also has issues in every wayland compositor. For example on hyprland it used to crash the entire desktop portal. I had to create a pull request to fix it. In gnome it still "crashes" the desktop portal if you change a hotkey. Hotkeys stop working in the application even if you restart it. You have to restart the desktop portal instead.
There is also the issue where desktop portal "security" verifies the identity of a process based on its process tree, so if that changes then all of the registered shortcuts disappear in the application. For example if you launch your application from the terminal and another time from the application launcher then they will have different set of registered hotkeys in your application. This can happen even if you for example change your application launcher to another one or change your display manager to another one.
How is a user supposed to know that?
It's so bad that in my next application I instead ignore wayland global shortcuts. I instead get root access and then do global hotkeys through the linux api directly. This works on both x11 and all wayland compositors, in the same way.
Last edited:
