0

I'm trying to get an application to run whenever a USB device is plugged in: Flash drive, Camera, phone, etc. I'll probably start with a simple application like "Hello World". So basically, when I plug in a camera, flash drive, or phone I want my computer to spawn a "Hello World" application.

Is it possible to create this sort of functionality on the latest version of Ubuntu Linux? Would I need to create an application to listen for this event? What I would rather do is just have it work without having an to have an application running to catch it. Is this possible?

Anything I need to write will be in C. If someone could point me in the right direction, I would be very grateful.

Thanks, T

2 Answers2

3

What you want is a udev rule -- udev is a daemon that waits for kernel events (like hardware mounts) and processes a set of "rules" that you define. There's a nice tutorial here which has several examples at the end that match your request.

Adrian Petrescu
  • 16,629
  • 6
  • 56
  • 82
1

You should look into UDEV: http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html

On top of that I would suggest looking into hal: http://www.freedesktop.org/wiki/Software/hal Though it is starting to get old

Finally udisks: http://www.freedesktop.org/wiki/Software/udisks

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Patrick
  • 178
  • 1
  • 6