[SOLVED] Using UDEV to automatically run a script on optical disc mount?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Using UDEV to automatically run a script on optical disc mount?
I'm trying to get a script to run whenever an optical disc is mounted by the system but can't get it to work. I'm running Fedora 12 64bit and the drive is SATA device sr0.
Following online guides, I created a new rule file called '10-my.rules' in '/etc/udev/rules.d' which contains the following:
But nothing happens when a disc is mounted. The script itself runs fine manually and is clearly evident when launched so the problem must be the rule file. I've tried changing the name of the rule file in a few incremental steps from 10-my.rule to 99-my.rule to no effect.
I've gathered some information about my optical drive using the udevadm tool.
Here is the result of an info query:
Again, thanks for the help. The script I'm trying to run is very obvious when executed - it's an automatic disc ripper that firstly pops up a dialogue box via zenity for 30 seconds giving an option to exit the script, after that it rips whatever is in the drive, ejects the disc and sets up an encoding cue.
I tried smoker's idea of testing a simple rule
which had it's intended effect so the rule is working.
I suspect this may be an issue with my script being launch by the system instead of my user account or root. I'll look into more.
You're right, Catkin, and that was the problem. Zenity was taking down the script from the get-go since it was the first line in there. However I found a solution by adding an 'export DISPLAY' command to the code.
Once that was solved the UDEV command was easy; it will launch my script when a disc is mounted by the optical drive. Also, the rule file had to run last with the name "99-my.rule" in order to function.