Script in udev rule doesn’t run
Solution 1:
The problem is that you probably have tested numlockx in (as it's name suggests) some X environment. X clients (GUI programs that connect to X server, e.g. Firefox or GEdit) need to know the server to connect to, and also must pass some kind of authorization. Try logging in from plain console, no matter by root or plain user, and starting some GUI application: it will show some DISPLAY related errors because it doesn't know.
To fix this you need to set environment variable DISPLAY; if you have only one X server it almost always has the address :0.
Try this at plain console: type numlockx on
, and it will show "Error opening display!". Type DISPLAY=:0 numlockx on
, and it will work (worked for me at least).
So you may set this environment variable in udev or just launch sh -c 'DISPLAY=:0 numlockx <state>'
.
Solution 2:
these two commands can be used to debug udev problems a lot:
udevd --debug-trace --verbose
strace -p pid_of_udevd -f -e trace=open,exec
Note that args may changes on different version ...