Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Shortcut support on Wayland #28

Open
wusyong opened this issue Mar 1, 2022 · 3 comments
Open

Global Shortcut support on Wayland #28

wusyong opened this issue Mar 1, 2022 · 3 comments

Comments

@wusyong
Copy link
Member

wusyong commented Mar 1, 2022

Global Shortcut on Linux only works on x11 because wayland-protocols hasn't define anything yet.
There's a RFC about this.
While we can use some workaround or implement one our own, it won't be supported by all DEs.
We'll have to wait wayland decide to add this.

@Pajn
Copy link

Pajn commented Oct 10, 2022

There is now a desktop portal for this flatpak/xdg-desktop-portal#711

Draft implementation in KDE:
https://invent.kde.org/plasma/xdg-desktop-portal-kde/-/merge_requests/80
https://invent.kde.org/libraries/xdg-portal-test-kde/-/merge_requests/6

Gnome and wlroots only have tracking issues atm:
https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/47
emersion/xdg-desktop-portal-wlr#240

@ShellWen
Copy link

ShellWen commented Dec 8, 2023

org.freedesktop.portal.GlobalShortcuts has gained widespread support; all that is needed is for someone to write the D-Bus communication.

Vadoola added a commit to Vadoola/Tomotroid that referenced this issue Dec 29, 2023
There is a bit of restructuring here, as well as basic support for
global hot keys. I have only tested it on Windows 11. It should in
theory work on most "modern" versions of Windows, and Linux with X11, as
well as possibly MacOS. I don't have a Mac to test, and I haven't tested
it on X11 yet.

Wayland support is waiting on this bug to be resolved before it will work:
tauri-apps/global-hotkey#28
@Exidex
Copy link
Contributor

Exidex commented Dec 4, 2024

I have looked into implementing this with intention to upstream it but, unfortunately, it doesn't seem like a good idea to implement org.freedesktop.portal.GlobalShortcuts in this crate. At least not without public API overhaul.

Here's how GlobalShortcuts portal works:

  • you can bind a shortcut by providing a shortcut id string and a description of said shortcut that will be visible to the user in a system settings window. you can also optionally provide default modifiers+key
  • you cannot unbind said shortcut
  • you can get a list of previously bound shortcuts
  • you can listen on "activation" event (shortcut is pressed, event is repeated if shortcut is held) and "deactivation" event (shortcut is released)
    • this event contains shortcut id and timestamp among other things
  • and you can listen on "shortcut changed" event which will be sent if user changes shortcut in system settings window

Taking all this into account, for application developers, I think, it would be more reasonable to implement global shortcuts for wayland using separate crate like ashpd given how big the difference in API is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants