I'm setting up a computer for someone who is comfortable using a few older Windows 98-era educational games, especially the Living Books titles. The original computer died, and I'm configuring the games to run on a modern system using tools such as ScummVM and Wine where possible. I'd prefer not to rely on a virtual machine if I can avoid it.
The important part is making the computer simple to use: when a game CD is inserted, I want the system to identify the disc and launch the already-configured command for that game. I don't want to run the installer or depend on the disc's autorun program, since some of the older discs are worn and may not read every file reliably. I'll install and configure everything ahead of time.
I'm comfortable writing shell scripts, but I'm not sure what the best way is to trigger one when an optical disc is inserted, or how to reliably identify the disc by its label, UUID, or another identifier.
3 Answers
A label can work just as well as a UUID if the discs have useful, unique volume names. You could inspect the device with `blkid /dev/sr0`, then match `ID_FS_LABEL` or the ISO9660 label in your script. UUIDs are generally safer because labels can be duplicated or changed. Make sure the script handles the short delay between insertion and mounting, and do nothing or open the file manager when no known disc matches.
For a more system-level solution, use a udev rule that watches for optical block devices and starts a systemd service. The rule can match the filesystem label, while the service runs as the normal desktop user and calls your launcher script. The script can then determine which disc is present and start the configured game. This is more involved than the desktop settings, and udev runs with a limited environment, so you’ll need to explicitly specify the user, display/session environment, and executable paths. It’s a good option if you want the behavior to work consistently regardless of which desktop environment is installed.
On a desktop environment such as Cinnamon, you may be able to assign a custom action for inserted software CDs in the removable-media preferences. Point that action at a wrapper script. The script can wait for the disc to be available, read its filesystem UUID or label, look up the matching game, and then launch the corresponding Wine, ScummVM, or native command. For example, `blkid -s UUID -o value /dev/sr0` can return the disc identifier. Keep a small directory of executable launcher scripts named after each UUID, and have the main script run the matching one. That avoids relying on the CD’s own autorun files.

That’s the kind of fallback I was considering. I’ll probably start with the desktop removable-media action and move to a udev/systemd rule only if it isn’t reliable enough.