0
I would like a zenity
dialog popup to ask me if I would like to run a backup, when I attached a specific external drive.
Unfortunately, I am having trouble with the UDEV rule syntax. I've got this rule in /etc/udev/rules.d/test.rules
:
ACTION=="add", ATTRS{manufacturer}=="Western Digital", ATTRS{idVendor}=="1058", ATTRS{idProduct}=="1140", RUN+="/usr/local/bin/test.sh"
It's pretty basic, but:
- It gets triggered a dozen times in stead of once.
- It cannot 'speak' using
zenity
whentest.sh
goessudo -Hu <username> zenity --warning --text="Just some random text for now."
because udev is tucked away in the system and cannot find the window manager: Gtk-WARNING **: cannot open display: - It's not very edit-friendly, I wish there were some kind of rule where I can just type the LABEL for certain partitions on which I would like to trigger certain scripts.
I would like to see a general improvement for the UDEV rule, because apart from the many questions and answers about it, here and elsewhere, they all seem a bit different from each other and most of them trigger multiple times.
But most importantly, how, in any way, can I make the connection from here to a script in my home that has access to stuff like my session and my screen so that zenity
can work?
Thank you for the response and mentioning alternatives. You were right,
DISPLAY=:0
did the trick. This answer addressess subquestion 2, but as subquestion 1 predicted, I now get myzenity
popup about 30 times for 1 plugged in drive. Any idea how I can tone this down? Preferably I would like the script to be called with just the partition name as argument. (E.g. script is called 3 times with 3 partitions.)I also tried
udisks
because it seems so easy, but it just sits there claiming to be monitoring, but not reporting anything I plug in. Maybe it's not implemented correctly for Ubuntu. – Redsandro – 2013-04-22T13:24:14.300Ah
udiskctl
does monitor events. I will look into it further if I can't figure out how to do it in theudev
rules as initially planned. – Redsandro – 2013-04-22T13:33:13.640@Redsandro Please see updated answer. – Olaf Dietsche – 2013-04-22T16:03:12.653
Thank you. It's still a puzzle, but I'm better informed now. I have accepted your answer. – Redsandro – 2013-04-23T12:03:38.297