[dev] [dwm] Bluetooth XF86 keys not working

From: Anskrevy <zergrusherncrusher_AT_disroot.org>
Date: Mon, 16 Jan 2023 19:03:52 -0800

I've got XF86XK_AudioPlay bound in my config.h with the necessary
include file, and this hotkey works when I use my keyboard. However,
when sent from a pair of bluetooth headphones the hotkey isn't
triggered. I've got the following xev output which shows the two keys
are slightly different

Bluetooth event from xev:
KeyPress event, serial 34, synthetic NO, window 0x1c00001,
     root 0x6b2, subw 0x0, time 1714630, (-534,257), root:(623,303),
     state 0x0, keycode 208 (keysym 0x1008ff14, XF86AudioPlay),
same_screen YES,
     XKeysymToKeycode returns keycode: 172
     XLookupString gives 0 bytes:
     XmbLookupString gives 0 bytes:
     XFilterEvent returns: False

Keyboard event from xev:
KeyPress event, serial 34, synthetic NO, window 0x1c00001,
     root 0x6b2, subw 0x0, time 1664827, (-534,257), root:(623,303),
     state 0x0, keycode 172 (keysym 0x1008ff14, XF86AudioPlay),
same_screen YES,
     XLookupString gives 0 bytes:
     XmbLookupString gives 0 bytes:
     XFilterEvent returns: False

In line 3 of the xev output from the bluetooth event the keycode
is 208 instead of 172 which is returned by XKeysymToKeycode.

Looking at the output of xmodmap -pk | grep -E "(172|208)" we get:

     172 0x1008ff14 (XF86AudioPlay)
                0x1008ff31 (XF86AudioPause)
                0x1008ff14 (XF86AudioPlay)
                0x1008ff31 (XF86AudioPause)
     208 0x1008ff14 (XF86AudioPlay)
                0x0000 (NoSymbol)
                0x1008ff14 (XF86AudioPlay)

Formatted to look better.

At this point I've just got a lot of information but I'm not sure how to
get dwm to grab keycode 208 or why it's even different in the first
place. The only solution I can think of is adding a modified Key struct
where the KeySym is a KeyCode instead. This would require modification
to the grabkeys function or another function all together. The keypress
function would also need to be modified as there would now be two arrays
to search through.

I couldn't find a patch regarding this so I don't think I'm reinventing
the wheel. However, I do think my solution is poor and because of that
I'd like to know if anyone can think of cleverer solution to this issue.

Thanks for reading.
Received on Tue Jan 17 2023 - 04:03:52 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 17 2023 - 04:12:08 CET