RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    questions about runcommand.sh

    Scheduled Pinned Locked Moved Ideas and Development
    runcommand
    32 Posts 5 Posters 15.1k 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 meleu

      I was reading the runcommand.sh code searching for the point where the game starts. In a user point of view, it happens when no button is pressed or when the user choose "Launch" at the menu.

      In the code the game seems to start at the end of the code, after the exit 0. Am I correct?

      My intention is to execute a script after runcommand and before the start of the game.

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

        I haven't installed a recent version but I think this is the code and I would guess the game starts here:
        https://github.com/RetroPie/RetroPie-Setup/blob/0951d9d3581588822a5b66e2d990f8c7b5a17341/scriptmodules/supplementary/runcommand/runcommand.sh#L804

        Auto-scraper: https://github.com/sselph/scraper
        Donate to Extra-Life 2018 and help save lives: https://goo.gl/diu5oU

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

          @sselph
          I would like to execute a command after runcommand and before the start of the game without the need to change the runcommand.sh file itself. I think it's not possible, since the runcommand calls the command that starts the game, right?

          • Useful topics
          • joystick-selection tool
          • rpie-art tool
          • achievements I made
          S 1 Reply Last reply Reply Quote 0
          • S
            sselph @meleu
            last edited by

            @meleu Doesn't sound like it. If you don't mind me asking what do you want to do?

            Auto-scraper: https://github.com/sselph/scraper
            Donate to Extra-Life 2018 and help save lives: https://goo.gl/diu5oU

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

              @sselph Well, I made a script to choose the controllers for RetroArch players 1-4 (as you can see here: https://github.com/meleu/RetroPie-joystick-selection). The configuration is made by the joystick names, but In the end it's just the joystick index number.

              The problem is that if the joystick list order changes (adding/removing devices), the indexes change and the user need to execute the script again.

              If I could execute a command right before the RetroArch begins, I could keep a configuration based on the joystick name and substitute the name by the correct index only when the game begins.

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

                @meleu Couldn't you setup another "emulator" such that the runcommand calls your alternate, only the emulator it calls is a script you create that runs your command and then the emulator it replaces? If you want the command to run for one or two emulators this might work, but gets less practical if you want a command before EVERY emulator.

                For example, I want the same thing--I want to launch MESS such that it runs a command before opening a disk image. The command will copy configs around to make a custom keymap tailored for that specific disk image. Sounds very similar to what you want to do.

                My 4-player cocktail style cabinet built as a custom "roadcase"

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

                  @caver01
                  Yep, I've already thought of this solution. But I wouldn't like to change so many files.

                  OK, it can be satisfactory if it's just for me. But my intention is to implement it and release for everyone. And I think that messing with so many files will add an unwanted complexity to the joystick selection process.

                  Thanks anyway! :-)

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

                    I've just realized one thing: There is no need to execute a command AFTER runcommand. It can be before.

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

                      As reported here:
                      you can now place scripts at /opt/retropie/configs/all/runcommand-onstart.sh and /opt/retropie/configs/all/runcommand-onend.sh

                      Really useful for what I want to do!

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      caver01C 1 Reply Last reply Reply Quote 0
                      • caver01C
                        caver01 @meleu
                        last edited by

                        @meleu And can these include variables (like selected ROM name)? This is fantastic for what I want to do too!

                        My 4-player cocktail style cabinet built as a custom "roadcase"

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

                          @caver01 said in A question about runcommand.sh:

                          @meleu And can these include variables (like selected ROM name)?

                          oo oh... I don't think so...

                          Look how they are invoked:

                          runcommand-onstart.sh:
                          https://github.com/RetroPie/RetroPie-Setup/blob/master/scriptmodules/supplementary/runcommand/runcommand.sh#L763

                          runcommand-onend.sh:
                          https://github.com/RetroPie/RetroPie-Setup/blob/master/scriptmodules/supplementary/runcommand/runcommand.sh#L829

                          The ROM name usually is the 4th argument given to the runcommand.sh and the runcommand-on[start|end].sh do not have access to these arguments.

                          I think the function get_params on runcommand.sh creates a global variable rom, as we can see here (this variable isn't declared as local, so it's a global variable). Maybe you can give to @BuZz a good reason to export this variable and access it in runcommand-onend.sh.

                          OR BETTER YET: change the the commands that invoke these scripts adding $@ in the end so they both can get access to the runcommand.sh parameters.

                          • Useful topics
                          • joystick-selection tool
                          • rpie-art tool
                          • achievements I made
                          caver01C 1 Reply Last reply Reply Quote 0
                          • caver01C
                            caver01 @meleu
                            last edited by caver01

                            @meleu Yeah, it makes sense to have access to these variables. Looking back a few years, I had a system running the Maximus Arcade front end. Many of us probably remember this one. Anyway, one of the settings you could configure per emulator is a RUN BEFORE and a RUN AFTER command (with variables passed). Not everyone used it, but you could do some really flexible things with it that are very similar to how our runcommand is used to set the display resolution, for example. I used it to do a pre-config by copying a configuration file matching the ROM NAME (or rather, a disk image for MESS using that forwarded parameter) into the working directory for MESS on the pre-execution, then on post, I would save that config back to it's holding folder. This allowed me to load my keyboard map for a given disk image, and more importantly, edit the mapping using the MESS GUI, and when I exited, it would be saved. Later, that saved file would be recalled and copied back into place when that ROM (disk image) was selected.

                            This required two (three) things. 1. A pre/post execution script. 2. Passing parameters so the script was aware of the ROM selected. (3. a parameter for the emulator chosen).

                            Looking back, I suppose I could have used the ROM parameter in the emulator launch command to point to the appropriate config. I don't remember if I tried that or not. Maybe I did and it failed when the config didn't exist and this was my workaround.

                            Anyway, I'd really like to be able to do custom keys on disk images (mostly games) for the Apple II emulator. As far as I know, I can't customize the keys in LinApple via configs, so I am looking at MESS.

                            My 4-player cocktail style cabinet built as a custom "roadcase"

                            meleuM edmaul69E 2 Replies Last reply Reply Quote 0
                            • meleuM
                              meleu @caver01
                              last edited by

                              @caver01
                              I added it and made a Pull Request:
                              https://github.com/RetroPie/RetroPie-Setup/pull/1610

                              Let's wait if it'll be merged. Crossing fingers!

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

                                Ooops! It didn't... :~(

                                • Useful topics
                                • joystick-selection tool
                                • rpie-art tool
                                • achievements I made
                                caver01C 1 Reply Last reply Reply Quote 0
                                • caver01C
                                  caver01 @meleu
                                  last edited by

                                  @meleu Bummer, but I don't fully understand the reason. Thanks for asking a clarifying question.

                                  My 4-player cocktail style cabinet built as a custom "roadcase"

                                  BuZzB 1 Reply Last reply Reply Quote 0
                                  • BuZzB
                                    BuZz administrators @caver01
                                    last edited by BuZz

                                    @caver01 I put some more details on the PR.

                                    To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                    caver01C 1 Reply Last reply Reply Quote 0
                                    • edmaul69E
                                      edmaul69 @caver01
                                      last edited by edmaul69

                                      @caver01 the newest version of linapple does let you configure which controller, buttons and axis. If you download the newest one you need to copy the linapple.conf from the /opt/retropie/emulators/linapple/ to the /opt/retropie/configs/apple2 folder overwriting the old config

                                      caver01C 1 Reply Last reply Reply Quote 0
                                      • caver01C
                                        caver01 @BuZz
                                        last edited by

                                        @BuZz Makes sense. There is a better way obtain the chosen ROM and Emulator then? I'd certainly rather work within the overall vision than branch off on my own, especially if it's something others might be able use.

                                        My 4-player cocktail style cabinet built as a custom "roadcase"

                                        1 Reply Last reply Reply Quote 0
                                        • caver01C
                                          caver01 @edmaul69
                                          last edited by

                                          @edmaul69 said in A question about runcommand.sh:

                                          @caver01 the newest version of linapple does let you configure which controller, buttons and axis. If you download the newest one you need to copy the linapple.conf from the /opt/retropie/emulators/linapple/ to the /opt/retropie/configs/apple2 folder overwriting the old config

                                          I want to pick this up on another thread. This sounds promising!

                                          My 4-player cocktail style cabinet built as a custom "roadcase"

                                          1 Reply Last reply Reply Quote 0
                                          • BuZzB
                                            BuZz administrators
                                            last edited by BuZz

                                            There is - processing order needs to change - I will implement it.

                                            To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

                                            1 Reply Last reply Reply Quote 0
                                            • 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.