You are not logged in.
How can I make a udev rule launch a graphical application, like, for instance, feh?
I've tried creating a rule detects when a specific mass storage device is connected and executes a script (/root/.scripts/feh-camera.sh). The script exports DISPLAY and XAUTHORITY and everything seems to work.
However when I restarted a black screen appeared right after Loading Modules (that appears after Starting udev events). Removing the udev rule solved the problem, so I must be doing something wrong.
What's the right way of doing this?
Thanks in advance.
Last edited by Vieira (2010-05-06 22:38:49)
Offline
it's possible that your udev rule is catching at boot (was the device plugged in at that time?); in any event i'd try putting a simple
pgrep X &>/dev/null || exit 1
at the top of your script; that way, it will do nothing if X isn't running somewhere. hopefully that includes not crashing your boot process.
//github/
Offline
Device was not connected at boot but I'll try what you suggested anyway. Thanks for your help.
EDIT:
It's solved. It turns out the underlying problem was that exporting DISPLAY breaks the udev environment. For future reference solved it with:
45-foobar.rules
ATTRS{product}=="DSLR-A330", ATTR{removable}=="1", ENV{REMOVE_CMD}="/bin/umount /media/camera", RUN+="/bin/mount <bla bla>", RUN+="/bin/su vieira -c '/etc/udev/rules.d/45-foobar.sh'"
and the script, where the problem was, must not export anything, just set inline, i.e.
#!/bin/sh
HOME=/home/vieira DISPLAY=:0 /usr/bin/feh -r /mnt/camera
Last edited by Vieira (2010-05-06 22:35:39)
Offline