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

    External triggers from runcommand-onstart.sh

    Scheduled Pinned Locked Moved Help and Support
    runcommandscriptingbash
    5 Posts 3 Posters 432 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.
    • R
      Rens
      last edited by Rens

      X86_64 - Ubuntu Server 24.04.2 LTS
      Script version 4.8.9

      I'll preface this with I am my worst enemy and I am probably over reaching in my capabilities, I am by no means a programmer but can work with python files.

      Reding the various posts a lot of things can be done with runcommand-onstart.sh and I have Ideas.
      And I set up a 2nd retropie to experiment... without stuffing too much up.

      I get there are multiple variables onstart.sh uses as per: https://retropie.org.uk/forum/post/23378

      To see what they produce can I (for example):

      echo $rom > ~/test.txt

      To then later use these outputs in a command for an external program?

      mituM 1 Reply Last reply Reply Quote 0
      • mituM mitu moved this topic from Ideas and Development
      • mituM
        mitu Global Moderator @Rens
        last edited by

        @Rens said in External triggers from runcommand-onstart.sh:

        To then later use these outputs in a command for an external program?

        Not sure what that means - perhaps you'd better explain what you'd like to accomplish during the onstart phase ?

        R 1 Reply Last reply Reply Quote 0
        • R
          Rens @mitu
          last edited by

          @mitu Sorry for the delayed reply...

          The plan is to drive an LED matrix, not unlike pixelcade has done, but from scratch.
          I'm running rpi-rgb-led-matrix on a raspberry pi-zero currently separately from the retro-pie.

          Onstart I want to run a script, that ssh into the pi-zero and runs led-image-viewer with art based on the rom file or if no art found a default image for system/emulator

          So as i understand it I need to see what the variable contains to then tie it to an image.

          mituM 1 Reply Last reply Reply Quote 0
          • mituM
            mitu Global Moderator @Rens
            last edited by

            @Rens said in External triggers from runcommand-onstart.sh:

            Onstart I want to run a script, that ssh into the pi-zero and runs led-image-viewer with art based on the rom file or if no art found a default image for system/emulator

            Alright, though I don't see the connection with the output part.

            Regardless, you can run your scripts from the onstart event handlers and they can do everything a script can, including writing files with variables received by the onstart handler (ROM file, SYSTEM, etc.)

            1 Reply Last reply Reply Quote 1
            • S
              sleve_mcdichael
              last edited by

              @Rens I think you're asking what parameters are passed to the onstart/onend scripts. It is just the four mentioned in the docs: $1 = system, $2 = emulator, $3 = rom path and $4 = command

              https://retropie.org.uk/docs/Runcommand/#runcommand-scripts

              Useful data are passed as arguments to these scripts:

              • $1 - the system (eg: atari2600, nes, snes, megadrive, fba, etc).
              • $2 - the emulator (eg: lr-stella, lr-fceumm, lr-picodrive, pifba, etc).
              • $3 - the full path to the rom file.
              • $4 - the full command line used to launch the emulator.

              You can see here, for example, the runcommand-onstart.sh and others are called with the user_script function:

                  user_script "runcommand-onstart.sh"
              

              The function:

              https://github.com/RetroPie/RetroPie-Setup/blob/cdb2bda29fab4cae57ca5bf283f87620ab4be851/scriptmodules/supplementary/runcommand/runcommand.sh#L1300

              # calls script with parameters SYSTEM, EMULATOR, ROM, and commandline
              function user_script() {
                  local script="$CONFIGDIR/all/$1"
                  if [[ -f "$script" ]]; then
                      bash "$script" "$SYSTEM" "$EMULATOR" "$ROM" "$COMMAND" </dev/tty 2>>"$LOG"
                  fi
              }
              

              The meat is here:

                      bash "$script" "$SYSTEM" "$EMULATOR" "$ROM" "$COMMAND" </dev/tty 2>>"$LOG"
              

              As you can see, only the four parameters "$SYSTEM" "$EMULATOR" "$ROM" "$COMMAND" are passed to $script

              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.