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

后端 未结 4 1000
再見小時候
再見小時候 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条回答
  •  Happy的楠姐
    2020-11-27 10:45

    I haven't tried writing such a program myself, however I've just looked at the following two links (thanks Google!), which I think will be of help:

    • dbus-python tutorial (which talks about how to use Python to access D-Bus)
    • HAL 0.5.10 Specification (which talks about how HAL publishes events to D-Bus)

    In particular, read about the org.freedesktop.Hal.Manager interface, and its DeviceAdded and DeviceRemoved events. :-)

    Hope this helps!

提交回复
热议问题