RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    [SOLVED] Variables with runcommand-onstart.sh

    Scheduled Pinned Locked Moved Help and Support
    runcommandscriptingbash
    25 Posts 7 Posters 13.8k 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.
    • meleuM
      meleu
      last edited by

      Here is a proof:

      $ time find /usr -type f -print -quit
      /usr/i686-w64-mingw32/bin/ar.exe
      
      real    0m0.266s
      user    0m0.000s
      sys     0m0.140s
      
      $ time find /usr -type f | head -1
      /usr/i686-w64-mingw32/bin/ar.exe
      
      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.)

      • Useful topics
      • joystick-selection tool
      • rpie-art tool
      • achievements I made
      1 Reply Last reply Reply Quote 1
      • obsidianspiderO
        obsidianspider
        last edited by

        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

        1 Reply Last reply Reply Quote 1
        • Nathan1031982N
          Nathan1031982
          last edited by

          @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.

          meleuM 1 Reply Last reply Reply Quote 1
          • meleuM
            meleu @Nathan1031982
            last edited by

            @Nathan1031982 The script he posted above gives a good direction to your script.
            The runcommand wiki can give some inspiration too: https://github.com/retropie/retropie-setup/wiki/runcommand#runcommand-onstart-and-runcommand-onend-scripts

            • Useful topics
            • joystick-selection tool
            • rpie-art tool
            • achievements I made
            1 Reply Last reply Reply Quote 1
            • F
              Finch106
              last edited by Finch106

              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/runcommand-onstart.sh
              
              # get the full path filename of the ROM
              rom=$3
              
              # rom_bn receives $rom excluding everything from the first char to the last slash '/'
              rom_bn="${rom##*/}"
              
              # rom_bn receives $rom_bn excluding everything from the last char to the first dot '.'
              rom_bn="${rom_bn%.*}"
              
              # get the system name
              system=$1
              
              # 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}" ]];
              then
                 img="/opt/retropie/configs/all/emulationstation/downloaded_images/$system/$system.jpg"
              fi
              
              # run the python script to display the image
              sudo fbi -T 2 -d /dev/fb1 -noverbose -a "$img"
              
              1 Reply Last reply Reply Quote 1
              • 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.