0

How can I tell my Ubuntu installation to execute some scripts when I connect a specific hardware?

For example: I have an external eSATA disk. When this (and only this) disk is plugged in, my notebook should execute the backup.sh script.

Additionally it would be nice if I get informed about those automatic executions. The most beautiful thing would be an indicator in my gnome panel. But a terminal that pops up and shows the output of the script would also be ok.

3 Answers 3

1

it is possible to tell udev to execute something when the device is plugged in. Here http://blog.deadlypenguin.com/blog/2009/09/25/automatic-backups-with-udev/ you see how someone else has done it with a usb disk, doing it with a e-sata disk should be very similar.

0
1

You'd have to have the script running as a user daemon, listening for hal events over D-Bus.

1

You can use RUN in a udev rule to accomplish at least part of this. See for example this howto: https://help.ubuntu.com/community/UsbDriveDoSomethingHowto

That doesn't cover notification or output -- you could have the script put its results in a file, and have something else running in your account monitor that file. (There's a number of existing programs made to monitor files in a GUI -- there's a gkrellm plugin, for example.)

The suggestion of making a background process listening to dbus events is another promising approach, and is in some ways more elegant (not the least being that you don't need to mess with system-wide configuration). But it also requires a little more linux-plumbing-level knowledge and programming work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.