Linux CDROM delete / insert detection

Is there a clean way to detect or receive events when a user inserts or removes a Linux CD?

+3
source share
3 answers

Udev monitors hardware and forward events on dbus. You just need a dbus listener. A quick check with the dbus monitor tool shows this on my system:

dbus-monitor - system

signal sender=:1.15 -> dest=(null destination) serial=144 path=/org/freedesktop/UDisks; interface=org.freedesktop.UDisks; member=DeviceChanged
   object path "/org/freedesktop/UDisks/devices/sr0"

This is a DeviceChanged event from Udisks, and the device path is enabled.

So, in any programming language that you need that supports dbus bindings, you can listen to events (system bus).

+3
source

HAL ( ), -

HAL - . udisks, UPower . /DeviceKit .

DeviceKit

udisks, D-Bus

udisks, , , .

+2
0
source

Source: https://habr.com/ru/post/1794595/


All Articles