Conversation
|
For the 2.5 release, the equivalent patch is a little noisier but essentially the same. I am using this on NixOS successfully: diff --git a/src/device.c b/src/device.c
index c7bc5fb..6dd5587 100644
--- a/src/device.c
+++ b/src/device.c
@@ -53,7 +53,7 @@ static uint8_t resolve_device_capabilities(int fd, uint32_t *num_keys, uint8_t *
size_t i;
uint32_t mask[BTN_LEFT/32+1] = {0};
uint8_t capabilities = 0;
- int has_brightness_key;
+ int has_special_keys;
if (ioctl(fd, EVIOCGBIT(EV_KEY, (BTN_LEFT/32+1)*4), mask) < 0) {
perror("ioctl: ev_key");
@@ -90,9 +90,11 @@ static uint8_t resolve_device_capabilities(int fd, uint32_t *num_keys, uint8_t *
* false positives which need to be explcitly excluded by the user if they use
* the wildcard id.
*/
- has_brightness_key = mask[KEY_BRIGHTNESSUP/32] & (1 << (KEY_BRIGHTNESSUP % 32));
+ has_special_keys =
+ (mask[KEY_BRIGHTNESSUP/32] & (1 << (KEY_BRIGHTNESSUP % 32))) ||
+ (mask[KEY_POWER/32] & (1 << (KEY_POWER % 32)));
- if (((mask[0] & keyboard_mask) == keyboard_mask) || has_brightness_key)
+ if (((mask[0] & keyboard_mask) == keyboard_mask) || has_special_keys)
capabilities |= CAP_KEYBOARD;
return capabilities; |
|
I fear this may include too many false positives. IIRC some laptop drivers will put the power button on a node containing other things like trackpad buttons. If you aren't already aware, you should still be able to remap your power button by explicitly listing the id in your config file. The code you have amended is for keyboard detection using the wildcard. |
I was not aware, thank you!! It will be nice to be able to run stock keyd. I'm ok closing it (or for you to close it) if you think the false positive rate would be too high. On my laptop the power device has only the powe button on it and nothing else. |
For what it's worth, on 2.5 at least this doesn't seem to be the case. If I remove the patch then my power button remapping (which uses an explicit ID for the power button device) stops working. I'm using NixOS so the syntax is a little funny but the relevant section is |
Maybe this is too niche, but I would like to treat my power button as an extra key that I can remap.
My specific application is that I have a Framework 13 laptop, which has a very low-quality touchpad with buttons that don't work and no replacement options, and a power button with a bright glowing border that encourages young children to press it. Because of the children, I had to disable its "turn off the computer" functionality, and because of the bad touchpad, I was on the hunt for unused hard-to-hit-accidentally buttons to remap to middle-click-paste.