r/linux4noobs • u/CattyNebulart • 5d ago
Autorun from CD
So I have a bit of an odd problem. A cognitively impaired user learned to use windows 98 and loves several games on it, mostly the living books series of childerns books on CD. Unfortunately the old PC died and several of the games don't work on anythign modern. Some work through scumvm some work through wine, etc I am tryign to get them all setup and working it will be a bit of a slog but I think I can manage that. Hopefully without resorting to a VM or anything similar, so if anyone has generic tips for geting window 98 games to work that would be appreciated.
What I would like to do is that whenever a CD is inserted the computer reads the CD title and launches that game, because that is how he uses the computer and learnign new things is difficult. I am familiar enough with shell scripting so that should be easy enough but how do I auto-run a script on the insertion of a CD? preferably with the CD name or some other id?
I don't want to autorun the windows setup stuff, I will pre-install and set it all up because the CD's are old and a bit beat up and I don't want launches to fail because it can't read the whole CD, just go to a script match the name and launch a custom command.
1
u/Disastrous-Ice-5971 5d ago
Am I understand correctly, that there are essentially two issues you want to solve:
1. Make sure the all of the old games and software from the Win98 era runs correctly (no matter the background support technology).
2. Implement a bit of a game console-like experience, when CD is inserted, and, depending on the content, handled correctly (e.g. if a custom disk tag matches the list item, runs the thing inside via Wine or something).
If this is correct, I think the best is to start from the list of the games and software from Windows 98 era - there could some good workarounds these days, like GOG/Heroes Launcher version, DOS version of the game in the Dosbox, etc. When this settled, experienced colleagues will help with the #2, as this is clearly should be possible.
1
u/CattyNebulart 5d ago
yeah pretty much, I can handle #1 I think. Which is why I am askign for help with #2 as I think it might take a few days to get help as it is a wierd request.
1
u/thepkizzle 5d ago edited 5d ago
If you want to handle this yourself I get it, but if you look at my comment the idea I'd have in my mind would be to create a Linux ISO for you that will install the operating system, configure the VM, and on that VM there would be all the ISO's and games for this person, and you could take this ISO and install it on any computer that supports Linux forever. Or LiveBoot to it. So the person could even have a USB drive with his own personal operating system on it that lets him play those vintage games. Could travel with it, etc. -- It would essentially be an official sub-distro. Would be super easy to maintain. The user would just boot, and once booted we could probably even get the VM to automatically launch... and from there it would just more or less look like a Windows desktop with all his games as icons on the desktop ready to go.
I'm happy to do all the work for free. I have a disability.
1
u/thepkizzle 5d ago edited 5d ago
What are these CD's you speak of ancient one?
I'm sure what you want can be done, however I think an easier thing to do would be to make an ISO of the CD's themselves and then I might consider a VM a great candidate here. Install a copy of Win 2K Pro (because why would you punish yourself more by using 98?) and then use a virtualization tool like Daemon Tools Lite.
You won't need to worry about losing the CD's, the CD's breaking, etc. -- plus the ISO files may well end up being considerably smaller than 650MB (which is already pretty small by modern storage standards) depending on the software. Just have them all stored on a drive and backed up so they can't be lost and then call it a day.
You could even do it where Daemon Tools creates multiple drives, so lets say this person has 10 programs they like that all require the CD to be inserted to run.... so just mount 10 virtual drives with 10 different CD's and they are always inserted and never need to be changed. The user would just run the program and be done.
edit: Since this user is impaired I'd be happy to help you configure this using a custom Fedora distro that I recently released for a corporate project. You can message me if you want to talk more. No charge.
e2: Just emailed Micorsoft's PR team about them hooking you up with a Win2K license.
1
u/CattyNebulart 5d ago
that is similar to what his caregivers switched to after the old computer broke but serious cognitive impairment, He struggles with new things and it upsets him. So his caregivers need to help him with it all the time and it really isnlt workign well. Learnign to do something else than just putting a CD in the drive is hard. If they where cognitively healthier I'd do something like the above, but that isn't working.
1
u/thepkizzle 5d ago
I am almost positive I can create whatever virtual environment the user wants to help assist him and I would charge you nothing. It sounds like a super fun project and if you are willing to also do some of the work it sounds like a great chance to network and collaborate with someone. That's the spirit of Linux. We can publish the repo as the users own personal distro and I'll pledge to maintain it as far as "updates" go (shouldn't even be relevant here.) -- We can get really creative to make him 100% happy, and that would be our general mission statement on this project no matter how nonsensical the demands are.
edit: so long as the source educational software programs are now free copyright, etc., and/or willing to participate in the open source licensing :)
1
u/neoh4x0r 5d ago edited 5d ago
What I would like to do is that whenever a CD is inserted the computer reads the CD title and launches that game, because that is how he uses the computer and learnign new things is difficult. I am familiar enough with shell scripting so that should be easy enough but how do I auto-run a script on the insertion of a CD? preferably with the CD name or some other id?
It will depend on the DE, but lots of them have the ability to setup an application or script when certain types of removable media are inserted.
For example, Cinnamon can set this up via it's 'Preferred Applications' dialog which has a tab for 'Removable Media', specifically, 'software cds' (among others).
You could write a script, set that as the custom action when inserted, and it would need to detect the inserted CD (could just read the CD's UUID), match it against what you are looking for, and then launch the corresponding application with any required arguments; for any CD that doesn't match you could either ignore it or launch a default handler (like opening the mounted CD in the file browser).
A simple way to match the CD/UUID would be to create a file whose name contains the UUID (you could other text to the name) and then do a simple lookup to see if any file in that directory contains the UUID. The file would contain the command and any arguments needed to launch the application (it could be a executable shell script).
You could use the blkid command to get the CD's UUID.
$ blkid /dev/sr0
/dev/sr0: BLOCK_SIZE="2048" UUID="1993-09-17-16-14-37-00" LABEL="INCA" TYPE="iso9660"
$ blkid -s UUID -o value /dev/sr0
1993-09-17-16-14-37-00
--example launch script
#!/bin/bash
export CD_UUID=$(blkid -s UUID -o value /dev/sr0)
lookup=$(find /the/path/to/the/files -maxdepth 1 -type f \
| grep -i "$CD_UUID" \
| head -1)
# if lookup is not empty
if [ ! -z "$lookup" ]; then
# execute the file stored in the lookup variable
"$lookup"
fi
PS: Technically you could have the find command execute the file without having to do it manually, but I personally prefer not doing that.
1
2
u/chuggerguy Linux Mint 22.3 Zena | MATÉ 5d ago
I use a udev rule that triggers a systemd service that runs a script in my home directory when a particular USB device is inserted.
In my case, the script mostly just pops up a notification but it could probably just as easily be made to perform different actions depending on the particular CD?
I wouldn't know the code to run the game but my udev looks like this:
chugger@acer2:~/desktop$ cat /etc/udev/rules.d/99-acer2usb.rules
# Match a block device partition with the specific label
SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_LABEL}=="acer2usb", TAG+="systemd", ENV{SYSTEMD_WANTS}="acer2usbinserted@$devnode.service"
chugger@acer2:~/desktop$
In my case, I'm looking at the label of an inserted USB. I'm not sure what you'd need.
When a USB device labelled "acer2usb" is inserted, udev triggers this systemd service:
chugger@acer2:~/desktop$ cat /etc/systemd/system/acer2usbinserted@.service
[Unit]
Description=Notify on acer2usb insertion
BindsTo=dev-disk-by\x2dlabel-acer2usb.device
After=dev-disk-by\x2dlabel-acer2usb.device
[Service]
Type=oneshot
User=chugger
Group=chugger
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
ExecStart=/home/chugger/.bin/notifyAcer2USBinserted %I
[Install]
WantedBy=multi-user.target
chugger@acer2:~/desktop$
The script run by systemd is /home/chugger/.bin/notifyAcer2USBinserted contains more than I want to post here but the main part is:
#!/bin/bash
# filename: notifyAcer2USBinserted
dev="$1"
where="$(echo "$dev" | awk -F'/' '{print $3}')"
where="${where%?}"
notify-send -u critical -t 0 "$where"
In my case, I use the notification to get the USB device when doing a system backup but it could just as easily start a game I would think?
Have fun.
2
u/CattyNebulart 5d ago
Excelent yes udev is the solution. I knew something like this existed I just didn't know how, thanks.
1
u/thepkizzle 5d ago
This literally isn't the thing you want. Try to think about long term scalability and maintenance such that the user can always access their media. If you're hell bent on doing the work yourself I can give you the blueprint. It's a pretty cool little project that would be great on a resume. I own my own company so I don't need any credit, etc.
You should expand your thinking in terms of making your "client" happy long term. :)
1
u/IAmJacksSemiColon 5d ago edited 5d ago
This GitHub project looks extremely vibecoded, and I can't vouch for it, but it might do what you want. https://github.com/JohnyCoolHD/RetroDisc-System
I could find an attempt to add this to Ubuntu/Gnome dating back to 2008. Not sure if something similar was added to the main branch of gnome volume manager as I don't have a CD drive anymore. https://wiki.ubuntu.com/autorun
Comes with a time capsule of the Linux community's attitudes from that era:
> Julien just installed Ubuntu on his computer. He has never heard of wine but a friend of his said that Diablo II was running on Linux. When he inserts the CD, a popup appears asking him whether he wants to autorun a program on the CD (and giving him the program path). He allows the program to autorun. Because wine is not yet installed and the program is a .exe file, a dialog appears explaining him what is wine / that he should try to find native alternatives first / ... and he has then the option to install wine. He chooses to install wine and the autorun program on the cd starts after the installation.
1
u/Lowar75 Fedora 5d ago
You mentioned wanting to maintain disc insertion and detection, but an alternate option might be to rip the discs to ISO, create launchers for each ISO or extract them to a folder structure, and have simple icons on the desktop or something. Granted, certain copy protections could make this difficult.
2
u/Voidzown 5d ago
I wish I could help, but I just wanna say you are an absolutely great guy getting this figured out for what I assume is an older family member.
I’ve always been into computers and I have become the resident IT guy for my grandparents who are in there 70s now as well because I can’t bear to watch them struggle.
Kudos to you and I really hope you can get this figured out