Running a script on ROM start....
-
I have a big panel of LEDs I want to show some animations on as a marquee once a game is started. Im familiar with the runcommand-onstart.sh file and have got it working as below.
All the LED animation work I do is done using python so Ive got the runcommand-onstart-sh to run python script and pass the details of the ROM being run into the python file:
The runcommand-onstart.sh looks like this:#!/bin/bash # put this in /opt/retropie/configs/all/. /usr/bin/python3 /home/pi/pyarg.py $1 $2 $3
And the python file looks like this:
#!/usr/bin/python import sys #$1 - the system (eg: atari2600, nes, snes, megadrive, fba, etc). #$2 - the emulator (eg: lr-stella, lr-fceumm, lr-picodrive, pifba, etc). #$3 - the full path to the rom file. #[0] seems to be just this python progrmme name retrosys = sys.argv[1] emul = sys.argv[2] romfile = sys.argv[2] with open('start.txt', 'a') as out: out.write(retrosys + "," + emul + "," + romfile + '\n') #now do things #print("doing") #time.sleep(10) #print("done") #time.sleep(5)
It all works fine and I saved the ROMs to a text file just to check.]
This is great as allows me to know which ROM is running and then use the python script to show an appropriate animation on the LED display.
At the bottom of the python script, I want to loop an animation which would cause the runcommand-onstart.sh to run indefinitely and get stuck. I know this as I tried it with the 'sleep' command in python it just stops while this is completed
I know its a bit of a convoluted way of doing things but I really want to run the animations in python! Im not great on bash scripting and just wondered if there is a way to start the python script from the runcommand-onstart.sh and then carry on with loading the game?
-
Run the script in the background from the
onstart
script:/usr/bin/python3 /home/pi/pyarg.py $1 $2 $3 &
or
nohup /usr/bin/python3 /home/pi/pyarg.py $1 $2 $3
You should also take care of stopping the script when the emulator exits, from the runcommand
onend
script. -
@mitu Thats great, it worked, just added an & at the end. Thanks very much!
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.