Closed frsfnrrg closed 6 years ago
We've not (yet) found a way to do this automatically.
xmodmap -pm
is implemented here: https://cgit.freedesktop.org/xorg/app/xmodmap/tree/exec.c#n215
From #wayland:
08:38 <daniels> emersion: yeah, keyboard shortcuts are ... exciting. especially when you get to multiple layouts and realise that people want ctrl+w to work regardless of whether they're in cyrillic or latin mode
08:39 <daniels> emersion: anyway, yeah, there's i'm afraid no real connection between keysyms and modifiers, especially as you have things like latching modifiers
I've made a short script (https://github.com/frsfnrrg/shortcut/blob/master/shortcut.py) with
which to compare shortcut implementations. It requires Python3.6 and xev
. So,
shortcut_i3
) hence fast and bug free.Ctrl+a+b
from Ctrl+b+a
, and hardcodes modifiers. My translation is shortcut_sway
, which skips translated keysyms due to complexity.† shortcut_delta
is the shortcut behavior that I would prefer; a generalization of i3's behavior to short sequences of key combinations, such as Ctrl+m/Meta+r/Meta+s
. A keypress is a modifier keypress if the next key press has a different modifier state.†† We store the last N keypresses which are not modifier keypresses, and match regular shortcuts based on the suffixes of stored keypresses along with the current keypress (which may or may not be a modifier keypress) . (Thus Ctrl+Hyper_L
is a valid key combination.) Release shortcuts are triggered on any keyrelease when a stored keypress suffix matches; if multiple do, we pick the shortest match. [In an actual implementation, when a shortcut is triggered, the ring of stored keypresses is wiped so we don't overcall; this can't be shown in the script.]†(Isn't Unicode case normalization more appropriate? After all, some users might have keyboard states that translate QWERTY to Dvorak, and if they cared for key positions, they'd use bindcode
not bindsym
)
††Hopefully this would also identify latching modifiers.
Thank you for this issue. I wasn't able to bind ISO_Level3_Shift
which is the right option key on German Macintosh keyboards, but binding Mod5
worked. This issue was helpful for me.
Using wlroots & sway builds from today (swaywm/wlroots@12bf39a715b2 and 48c84cd1f).
My relevant environment variables are
And the relevant lines of
.config/sway/sway
areset $mod Mod5
andbindsym $mod+Return exec st
. Pressing keysCapsLock+Enter
should launchst
; it doesn't. The cause is thatkeysym_is_modifier
insway/input/keyboard.c
is overly specific in detecting modifiers; comparing withxmodmap
output, I findso that
keysym_is_modifier
is most likely missingXKB_KEY_Num_Lock
,XKB_KEY_Mode_switch
, andXKB_KEY_ISO_Level3_Shift
. (Now that I have added these cases to my local version of sway,CapsLock+Enter
does launchst
.)It would be nice if sway would identify which keysyms generate modifiers from the xkb API instead of using using a hardcoded list which only works with default keyboards.