You are not logged in.

#1 2010-05-06 18:02:58

Vieira
Member
From: Lisbon, Portugal
Registered: 2007-08-16
Posts: 45

[SOLVED] udev rule launch graphical app

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

#2 2010-05-06 18:24:18

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: [SOLVED] udev rule launch graphical app

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.

Offline

#3 2010-05-06 18:34:58

Vieira
Member
From: Lisbon, Portugal
Registered: 2007-08-16
Posts: 45

Re: [SOLVED] udev rule launch graphical app

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

Board footer

Powered by FluxBB