Emulation Station Bootup Theme Randomizer
-
I recently wrote a script that will automatically switch the ES theme upon bootup and randomly choose any themes you have installed.
It's a small script and a small 1-line addition to the autostart.sh script.
I placed the script into a folder I made called /home/pi/scripts and then made it executable (chmod +x).
After that, I added the line into the autostart.sh script to launch it.
/home/pi/scripts/themerandom.sh
# Get list of currently installed themes and count ls /etc/emulationstation/themes > /tmp/themes ls /opt/retropie/configs/all/emulationstation/themes >> /tmp/themes themecount=`cat /tmp/themes |wc -l` # Get the currently used theme name curtheme=`cat /opt/retropie/configs/all/emulationstation/es_settings.cfg |grep ThemeSet |cut -f4 -d '"'` # Generate a random number between 1 and theme count r=$(( $RANDOM % ${themecount} +1 )) # Read the random line in the tmp file to get a new theme name newtheme=`sed -n "${r}p" /tmp/themes` # Replace the current used theme with a new one perl -pi -w -e 's/<string name=\"ThemeSet\" value=\"'${curtheme}'\" \/>/<string name=\"ThemeSet\" value=\"'${newtheme}'\" \/>/g;' /opt/retropie/configs/all/emulationstation/es_settings.cfg
NOTE: make sure the long lines above (if you copy and paste them) stay as a single line, they may "word-wrap" on you. For example, that last line beginning with perl -pi is a very long line.
Then the new line added to autostart.sh as the first line.
/home/pi/scripts/themerandom.sh emulationstation #auto
Now, every time you start your RetroPie system up, it'll randomly pick an installed theme and make the change in the es_settings.cfg file before Emulation Station launches.
Hope some find it useful.
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.