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

    Scripting help for replacing retroarch.cfg

    Scheduled Pinned Locked Moved Help and Support
    copyconfig filescriptingautomatedoverlays
    49 Posts 4 Posters 8.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.
    • F
      FlashPC
      last edited by FlashPC

      Hi guys,

      I have been working on different configs for overlays and shaders within retropie and created the following files

      retroarch_shader.cfg
      retroarch_overlay.cfg
      retroarch_standard.cfg

      And I've been trying to write a very simple script which will copy one of these files over the top of the retroarch.cfg file which can be run from inside emulationstation / attract mode to avoid having to use a keyboard and the command line

      So once the script is run, it will replace the retroarch.cfg within the /opt/retropie/configs/{console in question} with one of the other files.

      I'm a total noob when it comes to linux, and working from other scripts I have found, I cannot seem to get it running. The code I have been using is as follows

      cp /opt/retropie/configs/3do/retroarch_shader.cfg /opt/retropie/configs/3do/retroarch.cfg

      and using a new line for each console.

      This creates either a retroarch.cfg? file (with an question mark at the end) but doesn't overwrite the original cfg file, but if I type the code above within the command line terminal it does what I want it to do.

      Please Help
      Paul

      TMNTturtlguyT 1 Reply Last reply Reply Quote 0
      • TMNTturtlguyT
        TMNTturtlguy @FlashPC
        last edited by

        @flashpc I probably have a script that I can modify to do what you want. I first have a few questions for you:

        1. (not really a question) Your command appears to be a simple copy command. You are copying a file name retroarch_shader.cfg from /opt/retropie/configs/3do/ and you are just copying it to the same folder location. The cp command is copy, not an overwrite command.
        2. I assume your intention is to overwrite the retroarch.cfg file? You want to be able to overwrite the file to run 1 of 3 different configurations, correct.
        3. Are you doing this for only 3DO? OR for all systems?
        1 Reply Last reply Reply Quote 0
        • F
          FlashPC
          last edited by

          Thanks for the reply,

          That's right, my intention is overwrite the retroarch.cfg within the same folder with either of the 3 files.
          And I'm intending to do this for all the systems that I've been working on (25 so far)

          TMNTturtlguyT 1 Reply Last reply Reply Quote 0
          • TMNTturtlguyT
            TMNTturtlguy @FlashPC
            last edited by

            @flashpc WOW - I have a script that will do what you want, but it would be a massive undertaking to write it for every system. If you want I can create a script for just one of your systems and then you can modify the script to add each of the other systems you want.

            F 1 Reply Last reply Reply Quote 0
            • F
              FlashPC @TMNTturtlguy
              last edited by

              @tmntturtlguy that would be great, cheers

              TMNTturtlguyT 1 Reply Last reply Reply Quote 0
              • TMNTturtlguyT
                TMNTturtlguy @FlashPC
                last edited by

                @flashpc here are the instructions - they are also in the script file.

                This script lets you switch retroarch config files. v1
                TMNTturtlguy - Sept 05 2017

                place script in /home/pi/RetroPie/retropiemenu/
                In order to run the script you must create the following folders:
                /opt/retropie/configs/all/emulationstation/retroarch_swap
                Then within that folder create a folder for each system:
                3do
                Then within that folder create the following 3 folders:
                overlay
                shader
                standard

                full example path for 3DO = /opt/retropie/configs/all/emulationstation/retroarch_swap/3do/overlay

                Within each folder you have created place a retroarch.cfg file. The file needs to be named the same in each folder. Place your current retroarch_shader.cfg in the shader folder. Name the fild retroarch.cfg.
                Restart EmulationStation and the script is located in the retropie menu

                • Take a look a the script and see if you can figure out how to add more systems. i currently have 3DO per your example and NES included. You need to create 3 lines for each system. For example, you need to copy lines A, B, C for both while true; do and case

                you then need to create 3 functions for each system. Simply copy them and change out the system names, ie, just copy the first 3 functions, change all 3do to psx for playstation.

                here is a download link for the script. mega download link

                Let me know if you have any questions.

                F 2 Replies Last reply Reply Quote 0
                • F
                  FlashPC @TMNTturtlguy
                  last edited by

                  @tmntturtlguy cheers buddy, its a bit late now, but I will have a go in the morning, thanks for this, it is very in depth, and I would have never have come up with anything like this.

                  Thank you very much

                  TMNTturtlguyT cyperghostC 2 Replies Last reply Reply Quote 0
                  • TMNTturtlguyT
                    TMNTturtlguy @FlashPC
                    last edited by

                    @flashpc You bet.

                    I have another idea, a cleaner script, but it would change all the systems to the same setup. Meaning you could run the script and it would change all systems to standard, or all systems to overlay. Would you prefer all systems to change at once? or would you like individual control like i have it set up now?

                    Thanks

                    1 Reply Last reply Reply Quote 0
                    • cyperghostC
                      cyperghost @FlashPC
                      last edited by cyperghost

                      @flashpc @TMNTturtlguy
                      I would rather use the User Menu and create three independent bash files.
                      The system name can be extracted by sytem call $1

                      So the script are easily placed here as the wiki explains...

                      and would look like

                      shaders on.sh

                      #!/bin/bash
                      # Replace retroarch configs in general
                      cp -f "/opt/retropie/configs/$1/retroarch_shader.cfg" "/opt/retropie/configs/$1/retroarch.cfg"
                      # Create file for detecting changes to shader
                      touch "/opt/retropie/configs/$1/shaderchange.tmp"
                      

                      in runcommand-onstart.sh you write

                      # Checks for `shaderchange.tmp` and reverts changes back if file is located
                      if [[ -f "/opt/retropie/configs/$1/shaderchange.tmp" ]]; then
                          cp -f "/opt/retropie/configs/$1/retroarch_standard.cfg" "/opt/retropie/configs/$1/retroarch.cfg"
                          rm "/opt/retropie/configs/$1/shaderchange.tmp"
                      fi
                      

                      The advantage is... you've a general method that only depends on system description of $1 command....
                      Maybe @meleu gots a much better idea ;)

                      F meleuM 2 Replies Last reply Reply Quote 0
                      • F
                        FlashPC @cyperghost
                        last edited by

                        @cyperghost can this script also change the overlay image in the retroarch/overlays folder?

                        cyperghostC 1 Reply Last reply Reply Quote 0
                        • cyperghostC
                          cyperghost @FlashPC
                          last edited by cyperghost

                          @flashpc It depends just on the cp command
                          cp -f "/opt/retropie/configs/$1/retroarch_overlay.cfg" "/opt/retropie/configs/$1/retroarch.cfg"

                          will show your overlay.

                          So you create three bash files for user menu... I'm pretty sure it will work for all systems as $1 uses system names!

                          1. cp overlays
                          2. cp shaders
                          3. cp standard (here comment out the touch command!)

                          The nice thing is, that with runcommand-onstart.sh every call will be checked if there was a system change and then the standard file will be changed back (if you don't want then just create the three bash files for User Menu and you are ready ;)

                          1 Reply Last reply Reply Quote 0
                          • F
                            FlashPC
                            last edited by

                            cheers guys, I'll have a play around tomorrow and see which option works best for the system I'm putting together.

                            Thanks again

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

                              @cyperghost said in Scripting help for replacing retroarch.cfg:

                              Maybe @meleu gots a much better idea ;)

                              Hello fellows. I'm little confused about the desired results here.

                              @FlashPC can you expand what are the results you expect?

                              EDIT: I've got the file copying/overwriting part, I'm just curious about what do you have in those files and if you want those configs only for some ROMs, etc.

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

                                @meleu the results I am trying to get is a script that will overwrite the retroarch.cfg file and a PNG file from either attract mode or emulation station without the need of a keyboard.

                                I have 3 copies of the retroarch.cfg file, one with the details for using custom overlays with additional crt shaders, one with just the crt shaders, and one with neither.

                                If you want to see the config files they are here

                                The outcome is to change the settings for the whole system, not just one game.

                                The person that I am making this build for can then choose whether they want;

                                All games for that system playable with a basic overlay with crt shaders.
                                All games for that system playable with a realistic overlay with crt shaders.
                                All games for that system playable with no overlay with crt shaders.
                                All games for that system playable with no overlay and no shaders.

                                Once they have made their decision, the games for that system will follow those rules until they decide to change it, even if they reboot the system.

                                Hopefully that makes sense

                                Paul

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

                                  @flashpc I think I've got what you want. I would use a different approach if I wanted those results. I would try to create new entries in the /opt/retropie/configs/SYSTEM/emulators.cfg, each new entry loading a different retroarch.cfg.

                                  Here is an example of how my emulators.cfg for NES looks like:

                                  lr-fceumm = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-fceumm/fceumm_libretro.so --config /opt/retropie/configs/nes/retroarch.cfg %ROM%"
                                  default = "lr-fceumm"
                                  

                                  I would add these lines:

                                  lr-fceumm-shader = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-fceumm/fceumm_libretro.so --config /opt/retropie/configs/nes/retroarch_shader.cfg %ROM%"
                                  lr-fceumm-overlay = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-fceumm/fceumm_libretro.so --config /opt/retropie/configs/nes/retroarch_overlay.cfg %ROM%"
                                  

                                  And then your friend could change the behaviour in runcommand menu, changing the "emulator".

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

                                    @meleu I like the idea, apart from the fact that they could potentially change aspects of the emulators, plus I can only seem to access the runcommand menu via a keyboard, and I am trying to change these with a controller only.

                                    @tmntturtlguy I ran the script and it is nice, but is there anyway control could be made with the controller. just like the way retropie_setup.sh does?

                                    TMNTturtlguyT meleuM 2 Replies Last reply Reply Quote 0
                                    • TMNTturtlguyT
                                      TMNTturtlguy @FlashPC
                                      last edited by

                                      @flashpc it should work with your controller. Did you follow the instructions and place the script in retropie menu folder? If run from the retropie menu it will run with a properly configured controller that is recognized as the first player.

                                      1 Reply Last reply Reply Quote 0
                                      • F
                                        FlashPC
                                        last edited by

                                        @TMNTturtlguy yeah you are right, it just works in emulationstation, I've manage to get it working within attract mode using joymap, like the old days and KODI.

                                        I really like the script, is there a way in which the first menu has you select the console and then a second menu will ask you to select a config

                                        I've changed the code slightly to match my setup, there is a lot of text, and it does work, I was just thinking once the system has been selected in the first menu can that variable be used to populate the file addresses in the second menu

                                        For example if you select Playstation in the first menu then it knows to look in the 'psx' folder

                                        Here is what I have so far

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

                                          @flashpc said in Scripting help for replacing retroarch.cfg:

                                          @meleu I like the idea, apart from the fact that they could potentially change aspects of the emulators,

                                          Not sure what you mean here.

                                          I can only seem to access the runcommand menu via a keyboard, and I am trying to change these with a controller only.

                                          Every connected controller can invoke runcommand menu. After choosing a game to play press the button you set for A several times until runcommand menu appears.

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

                                            @meleu from the runcommand you can select emulators for the complete system, as well as per game. If this is done and the game is not compatible with the new emulator then it wont load, (arcade for example) so I would like to avoid that as I will not be able to help once he takes the box away with him.

                                            and I don't know about accessing the menu from a controller, I tap the 'X' on my controller which is set to A in emulationstation and it just loads the games, but pressing 'ENTER' on the keyboard works every time.

                                            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.