How can I listen for 'usb device inserted' events in Linux, in Python?

后端 未结 4 1010
再見小時候
再見小時候 2020-11-27 09:48

I\'d like to write a Python script for Amarok in Linux to automatically copy the stackoverflow podcast to my player. When I plug in the player, it would mount the drive, cop

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 10:37

    I think D-Bus would work as Chris mentioned, but if you're using KDE4, you might use the Solid framework in a manner similar to the KDE4 "New Device Notifier" applet.

    The C++ source for that applet is here, which shows how to use Solid to detect new devices. Use PyKDE4 for Python bindings to these libraries, as shown here.

提交回复
热议问题