Skip to content

Instantly share code, notes, and snippets.

@ihipop
Created July 30, 2024 05:56
Show Gist options
  • Save ihipop/d8436232e0d8e350b50090c395177e14 to your computer and use it in GitHub Desktop.
Save ihipop/d8436232e0d8e350b50090c395177e14 to your computer and use it in GitHub Desktop.
Udev rules for logitech k380 bluetooth keyboard to make function (fn) keys locked
ACTION=="change", SUBSYSTEM=="power_supply", DEVPATH=="*:046D:B342.*", RUN+="/bin/bash -c \"DEV_RAW=/dev/$$(echo $$(ls -1 $$(echo /sys$${DEVPATH} |sed -E 's#(.*)/power_supply/.*#\1#g')/hidraw)); [ -c $${DEV_RAW} ] && echo -ne '\x10\xff\x0b\x1e\x00\x00\x00' > $${DEV_RAW} || true\""

There was ready a answer exists https://askubuntu.com/a/1363698

BUT!!

The hidraw* device becomes accessible exclusively when a new pairing device is created. It does not regenerate immediately upon Bluetooth disconnections or reconnections, nor when the keyboard's power is toggled.

My tests have confirmed that the creation and removal of the hidraw* device are not immediately triggered unless the Bluetooth pairing is cleared.

This phenomenon occurs specifically when the K380 keyboard switches Bluetooth configurations or is powered off and then back on. The triggering of the hidraw* device is delayed, happening after a certain period following a switch out or power cycle. It is imperative that we identify and select a more suitable event to reliably trigger this process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment