开发者

Ubuntu Linux - Spawning an application when a USB device is plugged in

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 functional开发者_如何学编程ity 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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜