Detecting the insertion of an optical disk

I need to do some activity in a Xojo console application (that is running as a daemon) whenever an optical disk is inserted. Does anyone have any idea how to go about this? It has to work on Linux and macOS. Windows is optional.

Thanks,

with or without plugins ?
There are macOS API’s under disk arbitration for watching for disk mounts & unmounts
https://developer.apple.com/library/archive/documentation/DriversKernelHardware/Conceptual/DiskArbitrationProgGuide/Introduction/Introduction.html

Windows has similar API’s
https://docs.microsoft.com/en-us/windows/win32/devio/detecting-media-insertion-or-removal

Not sure about Linux

For Windows check our WindowsDiskChangeMBS class in MBS Xojo Win Plugin.

For MacOS you can check NSWorkspaceMBS class with NSWorkspaceDidMountNotification to get the notification for a new disk.
Or CarbonApplicationEventsMBS for older projects where VolumeMounted event should still work.

Helpful links guys. Thanks.

Anyone know about Linux?

I just googled for “macOS detect disk insertion” and “windows detect disk insertion”

linux should be similar to find answers BUT you’re likely to get answers that vary from distro to distro - I find that to be really common in the linux world

for instance
https://askubuntu.com/questions/359855/how-to-detect-insertion-of-dvd-disc