bk138 / gromit-mpx

Gromit-MPX is an on-screen annotation tool that works with any Unix desktop environment under X11 as well as Wayland.
GNU General Public License v2.0
998 stars 83 forks source link

Shortcut keys are not working on Sway WM (Wayland) #127

Open Kadagaden opened 3 years ago

Kadagaden commented 3 years ago

(Redirected from https://github.com/bk138/gromit-mpx/issues/121)

I'm using Sway WM and the shortcut keys only work on xwayland windows (e.g. leafpad), and they don't work on the wayland windows (e.g. firefox, or foot terminal emulator). I can draw on wayland windows only if I start gromit-mpx then I use the command line for toggle, clear, etc. (But then I can't click on the workspaces and other stuff on swaybar, gromit-mpx has an overlay.)

Arch Linux gromit-mpx-git: 1.4.r38.g1920bc1-1 wayland: 1.19.0-1 sway: 1:1.5.1-2

bk138 commented 2 years ago

Until https://github.com/flatpak/xdg-desktop-portal/issues/624 adds some cross-platform way of doing this, additional code handling desktop-environment-specific cases in add_hotkeys_to_compositor() and remove_hotkeys_from_compositor() is needed.

Pull requests welcome!

bk138 commented 2 years ago

(But then I can't click on the workspaces and other stuff on swaybar, gromit-mpx has an overlay.)

This should be fixed by b7bb607e5789fa5a10416d5e9937428c48f68647.

hamedgk commented 2 years ago

@Ka-hu this is my workaround, Add this to your sway config run gromit-mpx executable press $mod+g to enter gromit-mpx mode, now you can use shortcuts press Esc or Enter to exit back to default mode

mode "gromit-mpx" {
    # toggle painting
    bindsym f9 exec gromit-mpx --toggle
    # clear
    bindsym Shift+f9 exec gromit-mpx --clear
    # toggle visibility
    bindsym Ctrl+f9 exec gromit-mpx --visibility
    # quit
    bindsym Alt+f9 exec gromit-mpx --quit
    # undo
    bindsym f8 exec gromit-mpx --undo
    # redo
    bindsym Shift+f8 exec gromit-mpx --redo

    # Return to default mode
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+g mode "gromit-mpx"
bk138 commented 2 years ago

@hamedgk thanks very much for that snippet. Is there any good way to add this to the sway config on Gromit-MPX startup and remove it again upon exit? I.e. does sway maybe have a config directory and a reload trigger?

hamedgk commented 2 years ago

@bk138 Yes, sway has a config directory and a reload trigger command. The default configuration file right after installation is /etc/sway/config custom user made configuration file is ~/.config/sway/config

swaymsg "reload" command reloads the config file :

~/.config/sway/config

if not exist then: /etc/sway/config

bk138 commented 2 years ago

@hamedgk That sounds like half the list is ticked. In addition, it would be way more robust if Sway could include a config snippet so that the app does not have to modify an existing config but rather drop a snippet in a config dir, then call reload.

hamedgk commented 2 years ago

@bk138 Sway can include other config files. Good news is: if our desired config file doesn't exist, reloading doesn't give an error. So you can drop snippet file upon exit, as you said. But anyway you have to edit the main config file once, in order to add inclusion statement like this: include ./gromit-mpx.conf

bk138 commented 2 years ago

https://github.com/flatpak/xdg-desktop-portal/issues/624#event-7439631234 might help, at least for flatpak 1.16.