runcommand.sh Improvement on Launch Images
-
Hello, I have been working on the runcommand.sh as it was bothering me that launch images don't go directly into editing the preferences for a rom unless you hit it twice. To fix this I made the follow change to two functions in runcommand.sh.
I added the follow code from:
if [[ -n "$image" ]]; then # if we are running under X use feh otherwise try and use fbi if [[ -n "$DISPLAY" ]]; then feh -F -N -Z -Y -q "$image" & &>/dev/null IMG_PID=$! sleep "$IMAGE_DELAY" else fbi -1 -t "$IMAGE_DELAY" -noverbose -a "$image" </dev/tty &>/dev/null fi
to
KEY_TEST=0 if [[ -n "$image" ]]; then # if we are running under X use feh otherwise try and use fbi if [[ -n "$DISPLAY" ]]; then feh -F -N -Z -Y -q "$image" & &>/dev/null IMG_PID=$! sleep "$IMAGE_DELAY" else IMAGE_TEST=$(fbi -1 -t "$IMAGE_DELAY" -noverbose -a "$image" 2>&1) KEY_TEST=$(echo $IMAGE_TEST | grep -z "\s/.*$" | wc -l) fi
this allows me to capture the output from fbi and grep on it to see if it has the image format at the end of the file, this has not been fully tested, but it works well for my needs. I am sure someone here who is smarter than me can think up a better idea.
Then for the check_menu it went from
local dont_launch=0 # check for key pressed to enter configuration IFS= read -s -t 2 -N 1 key </dev/tty if [[ -n "$key" ]]; then [[ -n "$IMG_PID" ]] && kill -SIGINT "$IMG_PID" tput cnorm main_menu
to
local dont_launch=0 # check for key pressed to enter configuration if [[ "$KEY_TEST" == 0 ]]; then IFS= read -s -t 2 -N 1 key </dev/tty fi if [ -n "$key" ] || [ "$KEY_TEST" == 1 ]; then [[ -n "$IMG_PID" ]] && kill -SIGINT "$IMG_PID" tput cnorm main_menu
above you can see that I basically used the KEY_TEST variable to determine if I need to wait for a key, so we skip that time out, then we check again if KEY_TEST == 1 then it does the menu like normal. The only possible flimsy part if the regex I use on the output from FBI, there is a possibility that if the image given to FBI is relative and FBI outputs something other than
/path/to/file.png
then it would break it. Ideally the regex would look specifically if the string ended in "png" or "jpg" but this worked for my needs.I tested that this works with and without launch images, but I have not tested it on all the different types of launch images. Your mileage may vary.
Full Functions Below:
function show_launch() { local images=() if [[ "$IS_SYS" -eq 1 && "$USE_ART" -eq 1 ]]; then # if using art look for images in paths for es art. images+=( "$HOME/RetroPie/roms/$SYSTEM/images/${ROM_BN}-image" "$HOME/.emulationstation/downloaded_images/$SYSTEM/${ROM_BN}-image" "$HOME/.emulationstation/downloaded_media/$SYSTEM/screenshots/${ROM_BN}" "$HOME/RetroPie/roms/$SYSTEM/media/screenshots/${ROM_BN}" ) fi # look for custom launching images if [[ "$IS_SYS" -eq 1 ]]; then images+=( "$HOME/RetroPie/roms/$SYSTEM/images/${ROM_BN}-launching" "$CONF_ROOT/launching" ) fi [[ "$IS_PORT" -eq 1 ]] && images+=("$CONFIGDIR/ports/launching") images+=("$CONFIGDIR/all/launching") local image local path local ext for path in "${images[@]}"; do for ext in jpg png; do if [[ -f "$path.$ext" ]]; then image="$path.$ext" break 2 fi done done KEY_TEST=0 if [[ -n "$image" ]]; then # if we are running under X use feh otherwise try and use fbi if [[ -n "$DISPLAY" ]]; then feh -F -N -Z -Y -q "$image" & &>/dev/null IMG_PID=$! sleep "$IMAGE_DELAY" else IMAGE_TEST=$(fbi -1 -t "$IMAGE_DELAY" -noverbose -a "$image" 2>&1) KEY_TEST=$(echo $IMAGE_TEST | grep -z "\s/.*$" | wc -l) fi elif [[ "$DISABLE_MENU" -ne 1 && "$USE_ART" -ne 1 ]]; then local launch_name if [[ -n "$ROM_BN" ]]; then launch_name="$ROM_BN ($EMULATOR)" else launch_name="$EMULATOR" fi DIALOGRC="$CONFIGDIR/all/runcommand-launch-dialog.cfg" dialog --infobox "\nLaunching $launch_name ...\n\nPress a button to configure\n\nErrors are logged to $LOG" 9 60 fi } function check_menu() { local dont_launch=0 # check for key pressed to enter configuration if [[ "$KEY_TEST" == 0 ]]; then IFS= read -s -t 2 -N 1 key </dev/tty fi if [ -n "$key" ] || [ "$KEY_TEST" == 1 ]; then [[ -n "$IMG_PID" ]] && kill -SIGINT "$IMG_PID" tput cnorm main_menu dont_launch=$? tput civis clear fi return $dont_launch }
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.