Spawning X apps in hotplug scripts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi folks -

I just gave my 9-year old daughter a digital camera for her birthday, it comes 
up as a usb storage class device and of course works fine.

The problem is I need to set it up suitable for a child to use on her laptop, 
and the default situation of mounting and unmounting is very poor for that.

I did some reading and discovered autofs (there is a tip about it at 
fedoranews.org), and was able to set this up with a timeout of two seconds, 
and that works quite well.  The autofs service is given a mountpoint and 
dynamically mounts the given device at the mountpoint *when the mountpoint is 
touched*.  It then umounts the device after the timeout period.

I did some further reading and was able to also set up a hotplug script 
specific to the camera IDs, which generates and deletes a symlink to the 
mount point when the camera is inserted and removed.

That gets me a /mnt/camera link that appears when the camera is inserted, as 
soon as you touch it, by ls /mnt/camera or anything else, the camera 
filesystem is mounted, accessed (so in the ls example you see the camera 
contents listed), and auto-umounted after the two second timeout period.  
When you pull out the camera the /mnt/camera link is removed. That's really 
nice.

But I want to go for gold and completely automate the process, such that 
merely plugging in the camera moves all the files in the camera to a 
specified directory and empties the camera.  I can do this with the hotplug 
shellscript using mv, but there is no feedback about the process and it is 
critical the camera is not removed too early.  What I want to use instead is 
the KDE kfmclient move command, which brings up a nice dialog with a progress 
bar that disappears at the end of the move action, same as a konqueror file 
move.  Then you need to wait three seconds, unplug the camera and you're 
done.  If this is possible I will write up a little howto bringing together 
all the pieces.

The problem is that although I can run a test kfmclient instance as root which 
works...

[root@fastcat root]# kfmclient move /mnt/camera/* '/home/agreen/pics'

this does not work when running from the hotplug script, presumably because 
that shell lacks some critical authentication or other information needed to 
allow X to accept it.  (Confession: I try this on an FC2 devel machine, but 
the question is relevant for all FC versions).

I looked around some more late last night, and saw that gPhoto2 has a script 
for this situation which should be able to run an X11 app from a hotplug 
script, called usbcam.x11-app.  The business end of that boils down to

su -l agreen -c "env DISPLAY=:0 HOME=/home/agreen kfmclient copy /mnt/camera/* 
'/home/agreen/Pics'"

trying this out gets me

Would you like to enter a security context? [y] n
bash: /root/.bashrc: Permission denied
Xlib: connection to ":0.0" refused by server
Xlib: No protocol specified

kfmclient: cannot connect to X server :0


My question is then: how can I spawn an X app, preferably with user 
credentials rather than root, from a hotplug script.

- -Andy

- -- 
Find your answer without waiting for replies....
Searchable list archives at 
http://marc.theaimsgroup.com/?l=fedora-list&r=1&w=2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAdn/ijKeDCxMJCTIRAjgVAJ9z1Gyxs2uwwmvn5EXmcg1uLXNJjQCfW1hh
qMdd1jaGsJsX4I4lCYLAH9U=
=HkDK
-----END PGP SIGNATURE-----



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux