linux - notify-send not working (in script) executed from udev -
i want notification in desktop particular usb device inserted.hence following udev rule.
kernel=="sd*",subsystems=="usb",action=="add",run+="/home/username/desktop/notify_script"
notify_script follows
#!/bin/sh su username -c 'notify-send "usb inserted"' echo usb_inserted >> /home/username/desktop/test_file
problem :
the above script works if executed root command line but, notify-send in script not working if executed udev.
question:
how make notify-send work udev? or there other way can achieve notification ?
possible invoke gui udev?
thank you.
the main problem is, udev-rule not run in xorg-related environment per default, not knowing display use. therefore fail, if want echo terminal gnome-terminal example. script, shall executed on udev-rule-match, must prior ui-related execution first export display. done via
export display=:0
i assume, problem, , notify-send run against wall.
i playing udev-rules, , managed work, though acting root, similar answer , 1 found here :
https://unix.stackexchange.com/questions/80882/udev-running-a-shellscript-that-accesses-an-x-display
and here
scripts launched udev not have display access anymore?
you might want check zenity. helpful small notifications
Comments
Post a Comment