awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.37k stars 598 forks source link

keygrabber: Shift modifier #2634

Open alfunx opened 5 years ago

alfunx commented 5 years ago

When setting keybindings for a keygrabber with Shift as modifier, the key must be specified in upper case as well. Consider this example:

awful.keygrabber {
    stop_key         = 'Escape',
    start_callback   = function() naughty.notify { text = "Start" } end,
    stop_callback    = function() naughty.notify { text = "Stop" } end,
    root_keybindings = { { { "Mod4" }, "g", function() end }, },
    keybindings      = {
        { { "Shift" }, "k", function() awful.client.focus.byidx(-1) end }, --doesn't work
        { { "Shift" }, "J", function() awful.client.focus.byidx( 1) end }, --works
        { {         }, "L", function() awful.client.focus.byidx( 1) end }, --doesn't work
    },
}

The first (and the third) binding won't work. However, for normal keybindings it's the other way around, the key must be specified in lower case, otherwise it won't work.

awful.key({ "Shift" }, "k", function() awful.client.focus.byidx(-1) end), --works
awful.key({ "Shift" }, "J", function() awful.client.focus.byidx( 1) end), --doesn't work
awful.key({         }, "L", function() awful.client.focus.byidx( 1) end), --doesn't work

Note that it's the same case if you add Mod4 as modifier. However, adding Control (or both Mod4+Control) as modifier makes the keygrabber behave like the global keybindings.

Those should probably be consistent. I think the way the normal keybindings are set at the moment is more intuitive, i.e. keys should be specified in lower case. Is there some limitation outside of Awesome for this? Didn't look at that code yet.

psychon commented 5 years ago

For shift this may seem obvious, but things like € are Alt-Gr + e for me and here it would be wrong to trat this as just e instead. So, I'm not really sure what the way to go here is. Perhaps just transform the resulting string to lowercase?

Is there some limitation outside of Awesome for this? Didn't look at that code yet.

The "normal keys" use just libxcb-keysyms and core-X11 protocol. The keygrabber code uses libxkbcommon and the XKB extension, thus do things "more properly". That's where the difference comes from, basically. (Feel free to search for bug reports saying that e.g. "this combination of keyboard layouts" causes problems; the reports say that the keyboard layout switch works fine in the prompt, but keybindings still use some other, old layout.)