Closed haysidney closed 12 months ago
Might be related to #576? Does your keyboard (lsusb
) also show up as two devices?
Here's my what my lsusb output looks like: lsusb.txt lsusb-verbose.txt lsusb-verbose-tree.txt
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
ID 1d6b:0002 Linux Foundation 2.0 root hub
|__ Port 3: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M
ID 0b05:19b6 ASUSTek Computer, Inc.
|__ Port 3: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M
ID 0b05:19b6 ASUSTek Computer, Inc.
|__ Port 3: Dev 2, If 2, Class=Human Interface Device, Driver=usbhid, 12M
ID 0b05:19b6 ASUSTek Computer, Inc.
|__ Port 3: Dev 2, If 3, Class=Human Interface Device, Driver=usbhid, 12M
ID 0b05:19b6 ASUSTek Computer, Inc.
I see multiple entries for 0b05:19b6.
If someone decides to tackle this bug I'm happy to test their code on my machine. In Nix I can point the keyd package to a branch and rebuild it easily. You can also just send me a patch and I can apply it and test it.
I found a hacky workaround for now. If I run input-remapper and map the keys to themselves, keyd can now register them.
What keyd sees from input-remapper:
input-remapper keyboard 0001:0001 brightnessup down
input-remapper keyboard 0001:0001 brightnessup up
Obviously I'd rather not have to run a whole other process just to get keyd to recognize the keys, but at least I can move on with what I'm working on now.
Can you post your full keyd config and the output of keyd monitor
while keyd is running? Press both the keys that are unresponsive as well as a few normal ones (a
, b
etc) and post the full output.
[ids]
*
[main]
capslock = f13
volumeup = command(sudo -E -u sidney pactl set-sink-volume @DEFAULT_SINK@ +5%)
volumedown = command(sudo -E -u sidney pactl set-sink-volume @DEFAULT_SINK@ -5%)
mute = command(sudo -E -u sidney pactl set-sink-mute @DEFAULT_SINK@ toggle)
micmute = command(sudo -E -u sidney pactl set-source-mute @DEFAULT_SOURCE@ toggle)
brightnessup = command(brightnessctl set +10%)
brightnessdown = command(brightnessctl set 10%-)
play = command(playerctl play-pause)
pause = command(playerctl play-pause)
playpause = command(playerctl play-pause)
next = command(playerctl next)
nextsong = command(playerctl next)
prev = command(playerctl previous)
previoussong = command(playerctl previous)
# Asus Zephyrus Specific
f21 = command(xinput set-prop "ASUE120A:00 04F3:319B Touchpad" "Device Enabled" $((1-$(xinput list-props "ASUE120A:00 04F3:319B Touchpad" | grep "Device Enabled" | grep -o "[01]$"))))
prog3 = command(asusctl led-mode -n)
kbdillumup = command(asusctl -n)
kbdillumdown = command(asusctl -p)
# Explicitly define these so that FFXIV doesn't
# prevent me from switching workspaces
[meta]
1 = M-1
2 = M-2
3 = M-3
4 = M-4
[altgr]
# Don't get in the way of r_alt enter
enter = macro(rightalt+enter)
j = left
k = down
l = right
i = up
o = backspace
u = backspace
p = delete
h = home
; = end
2 = <
4 = >
3 = |
w = {
r = }
e = '
s = (
f = )
d = "
x = [
v = ]
c = `
left = previoussong
right = nextsong
up = volumeup
down = volumedown
rightshift = playpause
[sidney@nixos:~]$ sudo keyd monitor
device added: 0fac:1ade keyd virtual pointer (/dev/input/event16)
device added: 0fac:0ade keyd virtual keyboard (/dev/input/event15)
device added: 0b05:19b6 Asus Keyboard (/dev/input/event12)
device added: 0b05:19b6 Asus Keyboard (/dev/input/event11)
device added: 0b05:19b6 Asus Keyboard (/dev/input/event10)
device added: 04f3:319b ASUE120A:00 04F3:319B Touchpad (/dev/input/event9)
device added: 04f3:319b ASUE120A:00 04F3:319B Mouse (/dev/input/event8)
keyd virtual keyboard 0fac:0ade enter up
Asus Keyboard 0b05:19b6 volumedown down
Asus Keyboard 0b05:19b6 volumedown up
Asus Keyboard 0b05:19b6 volumeup down
Asus Keyboard 0b05:19b6 volumeup up
Asus Keyboard 0b05:19b6 kbdillumdown down
Asus Keyboard 0b05:19b6 kbdillumdown up
Asus Keyboard 0b05:19b6 kbdillumup down
Asus Keyboard 0b05:19b6 kbdillumup up
Asus Keyboard 0b05:19b6 brightnessdown down
Asus Keyboard 0b05:19b6 brightnessdown up
Asus Keyboard 0b05:19b6 brightnessup down
Asus Keyboard 0b05:19b6 brightnessup up
keyd virtual keyboard 0fac:0ade a down
keyd virtual keyboard 0fac:0ade a up
keyd virtual keyboard 0fac:0ade b down
keyd virtual keyboard 0fac:0ade b up
keyd virtual keyboard 0fac:0ade c down
keyd virtual keyboard 0fac:0ade c up
keyd virtual keyboard 0fac:0ade f13 down
keyd virtual keyboard 0fac:0ade f13 up
keyd virtual keyboard 0fac:0ade rightalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade rightalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade left down
keyd virtual keyboard 0fac:0ade left up
keyd virtual keyboard 0fac:0ade rightalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade rightalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade c down
Also, here's the log from starting the keyd service:
[sidney@nixos:~]$ sudo systemctl status keyd
● keyd.service - keyd key remapping daemon
Loaded: loaded (/etc/systemd/system/keyd.service; enabled; preset: enabled)
Active: active (running) since Wed 2023-10-25 01:21:08 EDT; 15s ago
Main PID: 7644 (sudo)
IP: 0B in, 0B out
Tasks: 2 (limit: 47187)
Memory: 1.4M
CPU: 22ms
CGroup: /system.slice/keyd.service
├─7644 /run/current-system/sw/bin/sudo -E /nix/store/w9c198yyn66f9b11ah9vi3ydqx6znbla-keyd-2.4.2/bin/keyd
└─7645 /nix/store/w9c198yyn66f9b11ah9vi3ydqx6znbla-keyd-2.4.2/bin/keyd
Oct 25 01:21:08 nixos sudo[7644]: root : PWD=/ ; USER=root ; COMMAND=/nix/store/w9c198yyn66f9b11ah9vi3ydqx6znbla-keyd-2.4.2/bin/keyd
Oct 25 01:21:08 nixos sudo[7644]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=0)
Oct 25 01:21:08 nixos sudo[7645]: CONFIG: parsing /etc/keyd/default.conf
Oct 25 01:21:08 nixos sudo[7645]: Starting keyd v2.4.3 ()
Oct 25 01:21:08 nixos sudo[7645]: DEVICE: ignoring 0fac:1ade (keyd virtual pointer)
Oct 25 01:21:08 nixos sudo[7645]: DEVICE: ignoring 0b05:19b6 (Asus Keyboard)
Oct 25 01:21:08 nixos sudo[7645]: DEVICE: ignoring 0b05:19b6 (Asus Keyboard)
Oct 25 01:21:08 nixos sudo[7645]: DEVICE: match 0b05:19b6 /etc/keyd/default.conf (Asus Keyboard)
Oct 25 01:21:08 nixos sudo[7645]: DEVICE: ignoring 04f3:319b (ASUE120A:00 04F3:319B Touchpad)
Oct 25 01:21:08 nixos sudo[7645]: DEVICE: ignoring 04f3:319b (ASUE120A:00 04F3:319B Mouse)
Can you try adding 0b05:19b6
to your [ids]
section?
[sidney@nixos:~]$ sudo systemctl status keyd
● keyd.service - keyd key remapping daemon
Loaded: loaded (/etc/systemd/system/keyd.service; enabled; preset: enabled)
Active: active (running) since Wed 2023-10-25 01:40:09 EDT; 4s ago
Main PID: 10862 (keyd)
IP: 0B in, 0B out
Tasks: 1 (limit: 47187)
Memory: 1012.0K
CPU: 20ms
CGroup: /system.slice/keyd.service
└─10862 /nix/store/w9c198yyn66f9b11ah9vi3ydqx6znbla-keyd-2.4.2/bin/keyd
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: ignoring 0fac:1ade (keyd virtual pointer)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: match 1532:00b4 /etc/keyd/default.conf (Razer Razer Naga V2 HyperSpeed)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: ignoring 1532:00b4 (Razer Razer Naga V2 HyperSpeed Mouse)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: match 1532:00b4 /etc/keyd/default.conf (Razer Razer Naga V2 HyperSpeed Keyboard)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: ignoring 1532:00b4 (Razer Razer Naga V2 HyperSpeed)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: match 0b05:19b6 /etc/keyd/default.conf (Asus Keyboard)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: match 0b05:19b6 /etc/keyd/default.conf (Asus Keyboard)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: match 0b05:19b6 /etc/keyd/default.conf (Asus Keyboard)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: ignoring 04f3:319b (ASUE120A:00 04F3:319B Touchpad)
Oct 25 01:40:09 nixos keyd[10862]: DEVICE: ignoring 04f3:319b (ASUE120A:00 04F3:319B Mouse)
[sidney@nixos:~]$ sudo keyd monitor
device added: 0fac:1ade keyd virtual pointer (/dev/input/event16)
device added: 0fac:0ade keyd virtual keyboard (/dev/input/event15)
device added: 1532:00b4 Razer Razer Naga V2 HyperSpeed (/dev/input/event23)
device added: 1532:00b4 Razer Razer Naga V2 HyperSpeed Mouse (/dev/input/event21)
device added: 1532:00b4 Razer Razer Naga V2 HyperSpeed Keyboard (/dev/input/event20)
device added: 1532:00b4 Razer Razer Naga V2 HyperSpeed (/dev/input/event19)
device added: 0b05:19b6 Asus Keyboard (/dev/input/event12)
device added: 0b05:19b6 Asus Keyboard (/dev/input/event11)
device added: 0b05:19b6 Asus Keyboard (/dev/input/event10)
device added: 04f3:319b ASUE120A:00 04F3:319B Touchpad (/dev/input/event9)
device added: 04f3:319b ASUE120A:00 04F3:319B Mouse (/dev/input/event8)
keyd virtual keyboard 0fac:0ade enter up
keyd virtual keyboard 0fac:0ade a down
keyd virtual keyboard 0fac:0ade a up
keyd virtual keyboard 0fac:0ade b down
keyd virtual keyboard 0fac:0ade b up
keyd virtual keyboard 0fac:0ade c down
keyd virtual keyboard 0fac:0ade c up
keyd virtual keyboard 0fac:0ade f13 down
keyd virtual keyboard 0fac:0ade f13 up
keyd virtual keyboard 0fac:0ade rightalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade rightalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade left down
keyd virtual keyboard 0fac:0ade left up
keyd virtual keyboard 0fac:0ade rightalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade rightalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade right down
keyd virtual keyboard 0fac:0ade right up
keyd virtual keyboard 0fac:0ade rightalt down
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade rightalt up
keyd virtual keyboard 0fac:0ade leftcontrol up
keyd virtual keyboard 0fac:0ade leftcontrol down
keyd virtual keyboard 0fac:0ade c down
The keys that aren't working no longer appear at all in the monitor output.
[ids]
*
0b05:19b6
They are probably executing the commands, but the commands are not doing what you might expect. Try commenting out the brightness keys in your config and you should see them appear in the output.
Interesting. You're right. Commenting out the command bindings made them appear in the monitor output.
When I put the bindings back in the keys don't work from the systemd service, but when I run sudo keyd from a terminal they work, so I just need to troubleshoot that.
So it looks like what I was missing was explicitly adding the keyboard's id in the id section alongside the . I wouldn't have thought that would still exclude things. haha
Thank you. I'll see if I can figure out how to troubleshoot the systemd problem now.
I wouldn't have thought that * would still exclude things.
By default it should automatically detect most keyboards, but the detection logic requires the device to be able to emit most letter keys. Some laptops split the physical keyboard into multiple input devices, which keyd cannot automatically detect. It seems in this case your keyboard creates multiple devices with the same product/vendor id.
When I put the bindings back in the keys don't work from the systemd service, but when I run sudo keyd from a terminal they work, so I just need to troubleshoot that.
I am not entirely clear what you mean by this, but you are probably running into #229. I am not familiar with brightnessctl
, but keep in mind that the commands are executed as the user running the daemon (should be root), and you may need to set environment variables to get some programs to behave correctly.
Yeah, running pactl from the terminal with su doesn't work, so it's pretty clear it's a user/environment issue with systemd running keyd as root. I'm a little stuck on it at the moment. pactl in particular really doesn't seem to like it when another user tries to change the volume. I've gotten my keyboard brightness working though, so I know keyd is working at least.
This is definitely not a keyd issue at this point, I just need to potentially rethink what I'm doing. I want all my keybinds to be display server and window manager agnostic so having everything in keyd would be great. I wonder if I need to tweak the default NixOS systemd service for keyd to be a user service instead of a system service. Then hopefully everything would be running as my user and things would be happy.
From my perspective this has been resolved. I learned that in the ids section sometimes isn't enough for certain weird keyboards (laptops). I just needed to add my laptop keyboard's id alongside the to get things working.
I'm struggling to get my volume keys and my fn+fx keys working on my 2022 Asus Zephyrus G14 laptop.
In monitor mode I get the expected output:
But when I leave monitor mode keyd is completely unresponsive to these keys. If I run keyd with KEYD_DEBUG=1 I don't see them registering at all.
The bindings for everything else works as expected though. For instance I map capslock to f13 for push to talk and I have layers and whatnot set up for easier arrow keys. It's just my laptop's "special" keys that don't work, like volume and the fn+fx keys. When I connect a bluetooth keyboard that has fn+fx keys the bindings work for that keyboard, which is interesting.
I'm on NixOS Unstable and I've overlaid the keyd package with v2.4.3.