gromit-mpx icon indicating copy to clipboard operation
gromit-mpx copied to clipboard

Shortcut keys are not working on Sway WM (Wayland)

Open Kadagaden opened this issue 4 years ago • 9 comments

(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

Kadagaden avatar Apr 03 '21 07:04 Kadagaden

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 avatar Feb 04 '22 13:02 bk138

(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.

bk138 avatar Feb 04 '22 13:02 bk138

@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"

hamedgk avatar Aug 11 '22 13:08 hamedgk

@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?

bk138 avatar Aug 11 '22 14:08 bk138

@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

hamedgk avatar Aug 11 '22 14:08 hamedgk

@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.

bk138 avatar Aug 11 '22 14:08 bk138

@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

hamedgk avatar Aug 11 '22 15:08 hamedgk

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

bk138 avatar Sep 22 '22 16:09 bk138