Auto Fn-lock logitech k380 keyboard
by Tianren Liu
First find out the device name
grep -FH "HID_NAME" /sys/class/hidraw/hidraw*/device/uevent
Then send msg to lock/unlock Fn key
echo -ne "\x10\xff\x0b\x1e\x00\x00\x00" | sudo tee /dev/hidraw[num] # lock
echo -ne "\x10\xff\x0b\x1e\x01\x00\x00" | sudo tee /dev/hidraw[num] # unlcok
Automatic Solution
Create a file /etc/udev/rules.d/70-logi-k380.rules
with the one of following lines
ACTION=="add", SUBSYSTEM=="hidraw", KERNEL=="hidraw*", RUN+="/bin/bash -c \"if [[ '%p' == */bluetooth/*:046D:B342* ]]; then echo -ne '\x10\xff\x0b\x1e\x00\x00\x00' > /dev/%k ; fi\""
ACTION=="add", SUBSYSTEM=="hidraw", KERNEL=="hidraw*", SUBSYSTEMS=="hid", KERNELS=="*:046D:B342.*", RUN+="/bin/bash -c \"echo -ne '\x10\xff\x0b\x1e\x00\x00\x00' > /dev/%k\""
Based on answers below this question
tags: Ubuntu 20.04