RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Emulation Station Bootup Theme Randomizer

    Scheduled Pinned Locked Moved Ideas and Development
    emulationstatiothemesrandomized
    1 Posts 1 Posters 1.6k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dmmarti
      last edited by dmmarti

      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.

      1 Reply Last reply Reply Quote 4
      • First post
        Last post

      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.