:: [DNG] running script on eudev even…
Page principale
Supprimer ce message
Répondre à ce message
Auteur: Antonio Trkdz.tab
Date:  
À: [DNG]
Sujet: [DNG] running script on eudev event
Dear All,

I am struggling to understand how to run a script automatically upon
plugging a USB keyboard.
I know this issue is not directly related to Devuan, but I will certainly
appreciate a little help.

I created the following rule as /etc/udev/rules.d/90-usb-keyboard.rules:
ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="XXXX", ACTION=="add",
RUN+="/full/path_to/restore_space_as_modifier.sh"
and reloaded eudev (I am on ASCII).

The script essentially has to do this:

#!/bin/bash
/usr/bin/xmodmap -e "keycode 65=Super_L"
/usr/bin/xmodmap -e "keycode any=space"
/usr/bin/pkill xcape
/usr/bin/xcape -e "Super_L=space"

I have tried many things including:
wrapping the script inside another calling it with '&' at the end
piping it to '... | at now'
wrapping the code in the same way: '(...) &'
calling the execution of the script with full paths to bash and script
calling it with sudo -u user
add 'OPTION="last_rule"' to the rule itself...

it is not working, nothing happens, not even a simple echo something to a
file, the only command I have got working is touching a file with
'RUN+="/usr/bin/touch path_to/filename"

Most of the resources I have found on the web mention something called
systemd as a possible solution......:)
If you know how to solve this issue please help.
Thanks in advance.

Antonio