There is a baseDir variable for which you can designate the directory you want to monitor.
The variable monitors can be edited according to the lock files to be monitored and the corresponding script files to be executed when the lock files were created.
# /etc/udev/rules.d/80-filco-keyboard.rules
ACTION=="add",DRIVER=="usb",ATTRS{product}=="USB Keyboard",RUN+="touch /tmp/keyboard.lock && rm /tmp/keyboard.lock"
# /etc/udev/rules.d/81-wacom.rules
ACTION=="add",DRIVER=="wacom",RUN+="touch /tmp/wacom.lock && rm /tmp/wacom.lock"
Test to ensure the file /tmp/<device>.lock was created as attached the device. (inotifywait -m -e CREATE /tmp)
For gentoo:
# emerge -av ghc cabal cabal-install
#/$ cabal install hinotify
ghc -O2 -o watchtight.hexe watchtight.hsAdd the following line to where you want the monitor to be established, such as ~/.xinitrc and ~/.xprofile.
nohup /path/to/watchtight.hexe &
If you didn't compile the script, use the following line instead:
nohup runghc /path/to/watchtight.hs &