Skip to content

Instantly share code, notes, and snippets.

@cattleguard
Created April 22, 2016 21:35
Show Gist options
  • Save cattleguard/fcc3a9c40b08d41a8f58ff0d2100d3b1 to your computer and use it in GitHub Desktop.
Save cattleguard/fcc3a9c40b08d41a8f58ff0d2100d3b1 to your computer and use it in GitHub Desktop.
Adds a game to your retropie NES called 'Feeling Lucky' which launches a random game from your collection.
#!/bin/bash
# Description:
# Adds a game to your retropie NES called 'Feeling Lucky' which launches a random game from your collection
# INSTALL: Point your nes launcher in /etc/emulationstation/es_systems.cfg
# to this script. (e.g. /home/pi/NES_feeling_lucky.sh %ROM%)
flag="$HOME/RetroPie/roms/nes/Feeling Lucky.nes"
if [ ! -e "$flag" ]
then
touch "$flag"
fi
gamename=`basename "$1"`
if [ "$gamename" == "Feeling Lucky.nes" ]
then
files=($HOME/RetroPie/roms/nes/*)
exit `/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nes "${files[RANDOM % ${#files[@]}]}"`
else
exit `/opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ nes "$1"`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment