I'm having difficulties running a .sh script when I plug in a Bluetooth keyboard.
I'm using the following udev rule:
ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="./scripts/icleverkeybindings.sh"
The script doesn't appear to be activated when I connect my keyboard. I have also tried "./scripts/icleverkeybindings.sh", "/bin/bash /scripts/icleverkeybindings.sh", and "sh /scripts/icleverkeybindings.sh". I don't understand why this script is not activated.
If I instead use the following udev rule
ACTION=="add", SUBSYSTEM=="bluetooth", RUN+="/bin/mkdir /home/joe/tempfolder"
Then the folder /home/joe/tempfolder is created when I connect the keyboard.
I have saved the rule in /etc/udev/rules.d/50-addicleverkeybindings.sh. The permissions etc. are: -rw-r--r-- 1 joe root 80 Aug 11 19:53 50-addicleverkeyboard.rules.
The script that I'm trying to run is the following:
#!/bin/bash sleep 1 cheese remote_id=$( xinput list | sed -n 's/.*iClever IC-BK06 Keyboard .*id=\([0-9]*\).*keyboard.*/\1/p' ) [ "$remote_id" ] || exit xkbcomp -i $remote_id /scripts/icleverlayout.xkb $DISPLAY
And ls -la gives -rwxr-xr-x 1 joe root 222 Aug 11 20:00 icleverkeybindings.sh.
If I call simply /scripts/icleverkeybindings.sh from the terminal this works fine.
The script changes the key bindings for my keyboard, I added in the pause in case somehow the script was getting called before xinput knew the keyboard was there, and I added in cheese just to make sure that I knew if it was definitely getting called or not.
Can anyone advise me on how to change my rule so that the script is called?
EDIT: To clarify, I created a folder /scripts/, so /scripts/icleverkeybindings.sh is the absolute filepath