Please do not post a support request without first reading and following the advice in

[SOLVED] Variables with

  • @obsidianspider Your updated script with comments is really cool to share with others the bash tricks.

    I only would like to share two tips with you:

    1. The use of [[ ... ]] is preferred over [ ... ] or test ...; it reduces errors as no pathname expansion or word splitting takes place between [[ and ]] (I learned it in RetroPie Shell Style Guide)
    2. The common practice to check if a string is empty is to use [[ -z "$string" ]].

  • @obsidianspider
    Oh! I look more carefully: This line is wrong:

    img=$(find "/opt/retropie/configs/all/emulationstation/downloaded_images/${system}/${rom_bn}-image".* | head -1)

    What BuZz suggested is:

    img="$(find "/opt/retropie/configs/all/emulationstation/downloaded_images/${system}" -type f -name "${rom_bn}-image.*" | head -1)"

  • @meleu

    Thanks for all the help, I've updated the script with the suggestions you gave.

    I'm learning a LOT from this community and I want to share what I've learned so someone else can make something even better with their own project. The comments help because a lot of the examples you see online don't explain what a particular thing is doing, they just say "do this" but not why you should do that.

    Now that I've got the screen working and finding images properly the next step is a pushbutton to control a script that toggles the backlight…

  • Looks interesting! We've had a Pi in a Gameboy, now we need someone to create their own DS-like console with the artwork displayed on the second screen (!)

  • Hey guys! Just sharing a find trick I've learned today...

    Using this:

    find /directory -type f -name "filename.*" -print -quit

    Is better than use this:

    find /directory -type f -name "filename.*" | head -1

    Benefit: the -quit makes find exit immediately after the first match. Well, if we want the first match only, there's no need to let the find keep looking for files after the first match.
    OBS.: when using -quit you have to use -print, otherwise the find won't print the file name.

  • Here is a proof:

    $ time find /usr -type f -print -quit
    real    0m0.266s
    user    0m0.000s
    sys     0m0.140s
    $ time find /usr -type f | head -1
    real    0m2.093s
    user    0m0.140s
    sys     0m0.403s

    (Yeah, I'm not using an actual Linux system. It's Cygwin running on Windows. But the test is valid anyway.)

  • Nice find! I'm away on a business trip for the next two weeks and had to leave my Pi at home so I am hoping to find a way to mess with some scripts while it's inaccessible.

    I have Googled emulating a Pi in a VM but it doesn't seem like anyone's done that, just approximated things with installing Debian.

  • @obsidianspider
    This is right up my ally. I actually want to do something similar to this, but with something like a 20x2 LCD to just display the system and game title.
    However, I might want to get an OLED screen for displaying the information.
    I might ask you for some help setting up my own script..
    My only thing is that I will then need to make a custom case to hold the Pi, as well as the screen and keep it all clean.

  • @Nathan1031982 The script he posted above gives a good direction to your script.
    The runcommand wiki can give some inspiration too:

  • This is a very old topic, but I wanted to throw my script in so you can edit it to your liking. I don't have an Adafruit display, so I had to do some tinkering but you've all done the heavy lifting. Here are the minor edits for using a 3.5" display with fbi. Make sure you have the system.jpg images in the correct system rom folders.:

    # /opt/retropie/configs/all/
    # get the full path filename of the ROM
    # rom_bn receives $rom excluding everything from the first char to the last slash '/'
    # rom_bn receives $rom_bn excluding everything from the last char to the first dot '.'
    # get the system name
    # set the image file to the first result matching the ROM name - accounts for various possible file extensions
    img="$(find "/opt/retropie/configs/all/emulationstation/downloaded_images/${system}" -type f -name "${rom_bn}-image.*" | head -1)"
    # check to see if there was a file found (length of the file name not zero), if not, use an image based on system
    if [[ -z "${img}" ]];
    # run the python script to display the image
    sudo fbi -T 2 -d /dev/fb1 -noverbose -a "$img"

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.