How can I launch a specific game automatically when its CD is inserted?

0
6
Asked By MellowPine47 On

I'm setting up a computer for a cognitively impaired user who is comfortable with a simple Windows 98-style workflow and enjoys several children's games from the Living Books series. The original computer died, and the games don't all run reliably on modern systems. I'm working on configuring each title through tools such as ScummVM, Wine, or other compatibility options, and I'd prefer not to rely on a virtual machine if possible.

The main usability goal is that inserting a game CD should automatically identify the disc and launch the preconfigured command for that title. I can write the shell script and will install everything ahead of time, so I don't want to run the installers or depend on the CD being fully readable. Ideally, the system would detect the disc label, volume ID, UUID, or another reliable identifier, look it up in a mapping, and start the appropriate game. What is the best way to trigger a script when an optical disc is inserted on Linux?

3 Answers

Answered By CedarOrbit8 On

A desktop environment may already support custom actions for removable media. For example, Cinnamon can assign a script to run when a software CD is inserted. The script can query the optical drive with `blkid`, read the disc UUID or label, and use that value to select a launcher from a directory of preconfigured scripts. A mapping could associate each identifier with the right Wine, ScummVM, or other command. Unknown discs can simply be ignored or opened in the file manager.

Answered By RiverKite63 On

You may also want to make disc images of the games and keep backups. Mounting an ISO or using a small virtual machine can avoid problems with scratched discs and make the experience more consistent. Each game could have its own launcher, and the user would only need to select the game rather than repeatedly insert physical media. That said, if physical CDs are important to the workflow, a label or UUID-based insertion script should handle the automatic launching directly.

MellowPine47 -

I’m mainly trying to preserve the familiar insert-the-disc workflow, so I’ll first try the removable-media or udev approach. I’ll still make disc images as backups in case the originals become unreadable.

Answered By QuartzMango21 On

For a more system-level solution, use a udev rule to match newly added optical block devices and start a systemd service. The rule can inspect filesystem metadata such as `ID_FS_LABEL` or another identifier, then pass the device to a script. That script can wait for the disc to mount, determine its label or UUID, and launch the matching game as the intended desktop user. This is more setup than a desktop removable-media action, but it works independently of the particular desktop environment.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.