awesomeWM / awesomeWM/awesome

awful.keygrabber.run() does not consider Shift as a modifier key

Open
#3,545 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Lua
Stars
7k
Forks
632
Avg merge
1d 8h
Merged PRs (30d)
2

Description

**Output of `awesome --version`:**

awesome v4.3 (Too long)
• Compiled against Lua 5.3.6 (running with Lua 5.3)
• D-Bus support: ✔
• execinfo support: ✔
• xcb-randr version: 1.6
• LGI version: 0.9.2

**How to reproduce the issue:**

1. Place these functions and keybinds in your `rc.lua`:
```
local keygrabber = keygrabber
local gears = require("gears")

-- Helps print a table.
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end

function switch(dir, mod_key1, release_key, mod_key2, key_switch)
keygrabber.run(
function (mod, key, event)
print()
print("Start function")
print("mod:", dump(mod))
print("mod_key1:", mod_key1)
print("mod_key2:", mod_key2)
if gears.table.hasitem(mod, mod_key1) then
print("Key", key)
print("release_Key", release_key)
print("event", event)
if gears.table.hasitem(mod, mod_key2) then
print("GO PREV")
else
print("GO FORWARD")
end
end
end
)
end

globalkeys = awful.util.table.join(
awful.key({ "Mod1", }, "Tab",
function ()
switch( 1, "Mod1", "Alt_L", "Shift_L", "Tab")
end),
awful.key({ "Mod1", "Shift" }, "Tab",
function ()
switch(-1, "Mod1", "Alt_L", "Shift_L", "Tab")
end),
)
```
2. Press Alt and hold.
3. Press Tab and release it.
4. Press Shift and hold.
5. Press Tab and release it.

**Actual result:**

"GO PREV" was never printed. The full output:

```
Start function
mod: { [1] = Mod1,[2] = Mod2,}
mod_key1: Mod1
mod_key2: Shift_L
Key Tab
release_Key Alt_L
event release

Start function
mod: { [1] = Mod1,[2] = Mod2,}
mod_key1: Mod1
mod_key2: Shift_L
Key Shift_L
release_Key Alt_L
event press

Start function
mod: { [1] = Mod1,[2] = Mod2,}
mod_key1: Mod1
mod_key2: Shift_L
Key Tab
release_Key Alt_L
event press
INSIDE SWITCH
GO FORWARD
```

**Expected result:**

"GO PREV" should be printed because "Shift" was pressed and should be in the Modifier Table `mod`.

**Additional context:**

I'm trying to get this Alt+Tab switcher working. It can cycle forward, but not cycle back (when I Alt+Shift+Tab): https://github.com/berlam/awesome-switcher#configuration

X11 modifiers on my computer:
```
$ xmodmap
xmodmap: up to 4 keys per modifier, (keycodes in parentheses):

shift Shift_L (0x32), Shift_R (0x3e)
lock
control Control_L (0x25), Control_L (0x42), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
```
I'm on latest Arch Linux btw.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the rc.lua reproduction and trace the keygrabber.run() entry point, using the provided Alt+Tab and Alt+Shift+Tab sequence to observe the modifier table. The work is done when Shift is included in the reported modifiers and the reproduction prints "GO PREV" for the reverse switcher action.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.