Hi,
I am trying to create a Game Launcher in bash (shell script) for retroarch. I have some of the code already completed, but it turns out I want to make it more efficient. I would like to shorten the code so that instead of having a ‘menu’ to start the retroarch core, I would like to remove the menu, and I would like to allow the user to select any retroarch supported rom file from an array and when they select a supported rom file, the correct emulator will launch it automatically. Can someone guide me to getting that working?
Here’s my current code:
Please note, you can probably tell, I am no bash expert by any means, but I should be able to follow tutorials and piece things together…
#!/bin/bash
config="$HOME/.config/retroarch/retroarch.cfg"
core_snes="$HOME/.config/retroarch/cores/snes9x_libretro.so" core_nes="$HOME/.config/retroarch/cores/mesen_libretro.so" core_gb="$HOME/.config/retroarch/cores/sameboy_libretro.so" core_n64="$HOME/.config/retroarch/cores/parallel_n64_libretro.so"
case “$1” in *.fds) core="$core_nes" ;; *.nes) core="$core_nes" ;; *.smc) core="$core_snes" ;; *.sfc) core="$core_snes" ;; *.gb) core="$core_gb" ;; *.gbc) core="$core_gbc" ;; *.z64) core="$core_n64" ;; *.n64) core="$core_n64" ;;
esac
clear
PS3=’ Please enter your choice: ’ options=(“Play Nintendo Game” “Play Super Nintendo Game” “Quit”) COLUMNS=0 select opt in “${options[@]}” do case $opt in “Play Nintendo Game”) nes_roms="$HOME/.config/retroarch/roms/Nintendo/Nes/" file=
zenity --file-selection --filename="$nes_roms*" --file-filter=" "*"" --title="Select Nintendo Game"
retroarch -L $core_nes “$file” --fullscreen --config=$config; clear exit ;; “Play Super Nintendo Game”) snes_roms="$HOME/.config/retroarch/roms/Nintendo/Snes/" FILE=zenity --file-selection --filename="$snes_roms" --file-filter=" "*"" --title="Select Super Nintendo Game"
retroarch -L $core_snes "$FILE" --fullscreen --config=$config;
clear exit
;; "Option 3") "you chose choice $REPLY which is $opt" ;; "Quit")
clear break ;; *) echo “invalid option $REPLY”;;
esac
done
Brian