Ubuntu Linux - 插入 USB 设备时生成应用程序

发布于 2024-10-08 05:57:17 字数 287 浏览 0 评论 0原文

我试图让一个应用程序在插入 USB 设备时运行:闪存驱动器、相机、电话等。我可能会从一个简单的应用程序(如“Hello World”)开始。所以基本上,当我插入相机、闪存驱动器或手机时,我希望我的计算机生成一个“Hello World”应用程序。

是否可以在最新版本的 Ubuntu Linux 上创建此类功能?我需要创建一个应用程序来侦听此事件吗?我宁愿做的就是让它工作,而不需要运行应用程序来捕获它。这可能吗?

我需要写的任何东西都将用 C 语言编写。如果有人能指出我正确的方向,我将非常感激。

谢谢, 时间

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人间不值得 2024-10-15 05:57:17

您想要的是 udev 规则——udev 是一个守护进程,它等待内核事件(如硬件安装)并处理您定义的一组“规则”。这里有一个不错的教程,最后有几个符合您要求的示例。

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.

夏花。依旧 2024-10-15 05:57:17

您应该查看 UDEV: http://www.kernel.org /pub/linux/utils/kernel/hotplug/udev.html

最重要的是,我建议查看 hal: http://www.freedesktop.org/wiki/Software/hal 虽然它开始变老了

最后udisks:http://www.freedesktop.org/wiki/Software/udisks

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文