# Creating an udev rule for a bluetooth keyboard [SOLVED]

## ville.aakko

Hi!

I'm having trouble creating a udev rule for my bluetooth keyboard. Hope someone here can help me =). To cut right to the problem / culprit, is that the following rule does not seem work:

/etc/udev/rules.d/50-k810.rules: 

```
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{address}=="00:1F:20:A8:89:8C" \

 RUN+="/opt/bin/k810.sh %p"
```

A little more background: I have a logitech K810 as my primary keyboard on the HTPC in question (when I need one, actually primarily it's controlled vai a remote control). I need to run an executable to enable the F-keys to work as such by default (without pressing the Fn -key). I can do that manually (so that part is working), but that is a small PITA =).

I got the above udev rule and executable from here. Also there seems to be others struggling with the rule here: http://unix.stackexchange.com/questions/144417/making-udev-rule-for-bluetooth-keyboard

But with the above rule, the script is never run AFAICT. I know that since the script should write a log file to /tmp in any case (even if it would be doing something wrong). Here's the contents of the script:

/opt/bin/k810.sh:

```
#!/bin/sh

LOGFILE=/tmp/logfilek810sh.log

echo "RUN: at `date` by `whoami` act $ACTION \$1 $1 DEVPATH $DEVPATH DEVNAME $DEVNAME" >> ${LOGFILE}

echo "Setting F-keys on for your K810!"

if [ "$ACTION" == "add" ];

then

    # configure k810 ($DEVPATH) at $DEVNAME.

    /opt/bin/k810_conf -d $DEVNAME -f on

fi
```

Permissions of the files in question:

```
# ls -l /etc/udev/rules.d/50-k810.rules /opt/bin/k810*

-rw-r--r-- 1 root root   106 2014-06-12 16:48 /etc/udev/rules.d/50-k810.rules

-rwxr-xr-x 1 root root   304 2014-06-08 01:34 /opt/bin/k810.sh

-rwxr-xr-x 1 root root 13102 2014-06-07 22:05 /opt/bin/k810_conf

```

Cheers!

----------

## ville.aakko

Heh, well sometimes writing the problem to a forum will bring you to the solution by itself =)

In case someone has the same problem: putting the address in lower case to the rules file solves it! =D

This is how I figured it out: I tried slightly different google search and came up to this: 

http://cris.bytesnblades.net/2009/02/20/starting-gpsd-automatically-with-a-bluetooth-gps/

So, I figured I'd try to run udevadm info -a -n /dev/hidraw1:

```

  looking at parent device '/devices/pci0000:00/0000:00:12.0/usb3/3-3/3-3:1.0/bluetooth/hci0/hci0:43':

    KERNELS=="hci0:43"

    SUBSYSTEMS=="bluetooth"

    DRIVERS==""

    ATTRS{type}=="ACL"

    ATTRS{address}=="00:1f:20:a8:89:8c"
```

So, the address is shown with the letters in lower case - could it really be such a stupid error???? Previously I had used bluetoothctl to figure out the address (which is the same, but in CAPITALS). And - lo and behold - butting the address in lower case solved it!

Cheers, and thanks for your time!

----------

