I was wondering if anyone had a way to automatically run a command after automounter sees a new device and mounts it. My goal is to automatically sync over new podcasts to an mp3 player when it's mounted. I've searched around and haven't seen a simple way to do this. I'm trying to avoid writing a poller in a cronjob that looks for the device. :)
Thanks, Kyle
On Tue, 2006-07-25 at 15:05 -0500, Kyle Sexton wrote:
I was wondering if anyone had a way to automatically run a command after automounter sees a new device and mounts it. My goal is to automatically sync over new podcasts to an mp3 player when it's mounted. I've searched around and haven't seen a simple way to do this. I'm trying to avoid writing a poller in a cronjob that looks for the device. :)
The way to do it is to use a udev rule.
Or if you want something a bit more attached to your user's session rather than the system, you could investigate dbus/hal. This is how GNOME automatically mounts USB drives and CD drives as your user, among other things. In fact, one of the options I see under "Removable Media and Storage" is which command to run when a Portable Music Player is connected. It seems to be oriented to playing music locally, but I see no reason why you can't change the command to do your sync instead of starting rhythmbox.
Justin Dugger
On 7/25/06, Jason D. Clinton me@jasonclinton.com wrote:
On Tue, 2006-07-25 at 15:05 -0500, Kyle Sexton wrote:
I was wondering if anyone had a way to automatically run a command after automounter sees a new device and mounts it. My goal is to automatically sync over new podcasts to an mp3 player when it's mounted. I've searched around and haven't seen a simple way to do this. I'm trying to avoid writing a poller in a cronjob that looks for the device. :)
The way to do it is to use a udev rule.
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux)
iD8DBQBExnzotSqjk42zvwkRAtIWAJ4iWzkP2GsZqFSpv/vpOv5gX3+E2QCgv/MO dkhnAh0ut5NZKa2nK3XKVYE= =YRSk -----END PGP SIGNATURE-----
Kclug mailing list Kclug@kclug.org http://kclug.org/mailman/listinfo/kclug
On Mon, 2006-07-31 at 10:53 -0500, Justin Dugger wrote:
Or if you want something a bit more attached to your user's session rather than the system, you could investigate dbus/hal. This is how GNOME automatically mounts USB drives and CD drives as your user, among other things. In fact, one of the options I see under "Removable Media and Storage" is which command to run when a Portable Music Player is connected. It seems to be oriented to playing music locally, but I see no reason why you can't change the command to do your sync instead of starting rhythmbox.
That might be a nice option as long as it works. You'll want to create a .desktop file that causes the program to run in a terminal.
Also, note that hal is notified by udev via a socket. Hal, in turn, issues a dbus event. So if you want to do your own dbus listener, you could write something in Python or Ruby but it would have to run as a daemon.
All in all it would be easiest to do it from a udev rule; friendliest to do it from GNOME's dbus listener.