Game script - WINE games that require DVD/CD's

For discussion of topics specific to MythTV on linux
Post Reply
Robert Worrall
Junior
Posts: 16
Joined: Sun Jun 25, 2017 2:38 pm
Great Britain

Game script - WINE games that require DVD/CD's

Post by Robert Worrall »

Hello Everyone,

I have developed a script for starting Windows games (using WINE) within Mythgame. This is in particular for games that require a DVD/ CD to be present. I did not want to rip them to the drive as I did not want to fill up my SSD with the ISO's

Here is the code for the .sh file

Code: Select all

#!/bin/bash
#
# Script to play a game that requires a DVD/ CD to run
#

#first set up variables checking the CD/DVD is mounted
export MOUNT=**MOUNTPOINT**
export FILE=**FILECHECK**


#check if game drive is mounted
if grep -qs $MOUNT /proc/mounts; then 
  echo "It's mounted.";
else
  echo "It's not mounted." 
  udisks --mount **DEVICEPATH** & export DRIVEMOUNTING=$!
  #wiat for the drive to complete mounting
  wait "$DRIVEMOUNTING";
fi
#check the correct drive is mounted by doing a file check
 if [ -f $FILE ]; then 
 #get the PID of the running game
  **GAME_EXECUTE** & export GAMEPID=$!
 #wait for the game to stop
 wait "$GAMEPID";
sleep 5s
#This game spawns a process outside of this script so lets get it. 
 export GAMEPID2=$(pgrep **GAME_PROCESS_NAME**)
 #Un commnet the line below if you find the mythtv front end comes to the front and you an hear but not see the game
 #dcop konqueror-[] konqueror-mainwindow#1 raise
 
 #Unmount the DVD/CD because we do not need it now - save it spinning.
 # umount /dev/sr0 
 
  else
  # the file check has failed and the disk is not inserted
   echo "File $FILE does not exist incorrect drive mounted."
# unmount the drive if there is any mounted
   umount /dev/sr0 
fi

# As this game will run outside of the this script so lets get's pid and wait for it to stop
# first "see if game is running"
 # check if the game is sill running.
 if  pgrep Quake4.exe && echo Running; then
  #start the joypad
  qjoypad --notray &  export PIDJOYPAD2=$!;
  else
  echo "Game not running"
  fi
 
 #lets wait for the game to stop
 while kill -0 $GAMEPID2 2> /dev/null; do
  sleep 1s;
 done
 
#the game has stopped lets stop the qjoypad
#kill $PIDJOYPAD2;
For each game using the above code, use the Find and replace feature in your text editor and replace the following:

Search Term Replace with
**MOUNTPOINT** path the drive mounts to after udisk has mounted it
**FILECHECK** path of a unique file on the DVD to ensure the correct disk in the drive
**DEVICEPATH** the device path of the dvd/cd drive e.g /dev/sr0
**GAME_EXECUTE** The excution command to start the game.
**GAME_PROCESS_NAME** The name of the process as some games spawn a process outside of the script and we can not use the wait command for these.


If you use Qjoypad then uncomment lines 47 and 58
Once the game has started you can unmount the DVD/CD by uncommenting line 31 thou this can cause problems with some games.
If you find the mythfront end returns to the top and you can hear the game in the background if you are running KDE uncomment line 55.

I have included the qjoystick commands because I could not get WINE to recognise my gamepad and had to configure is with qjoypad instead.

I also use KDE so I could not include any alternative commands for brining the window to the front (if needed) for any of the other desktops. This is because I did not want to include anything I could not test myself.

I hope this is of some help to anyone wanting to put their old windows games on their mythfrontend.

I was wondering if this is something that could go on the Mythgame wiki page but given my lack of experience in contributing, let alone coding I thought perhaps it would be better placed here?

Kind regards

Rob
Post Reply