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.
    • 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
                              • TMNTturtlguyT
                                TMNTturtlguy @FlashPC
                                last edited by

                                @flashpc Wow, you have done a lot of work on this! As far as adding a second menu, I am sure there is a way to do it. I am not an expert on scripts, i just know enough to be dangerous! So my short answer is, I don't know how to do it off hand. I would have to spend some time researching/playing with it. Maybe @meleu can share some insight on how to modify the main menu and and add a second menu for each console.

                                My other thought would be to simplify the entire script so that the end user only has 3 choices.

                                1. Standard
                                2. Shaders
                                3. Overlay

                                When they select any of the options, the script runs and sets all emulators to the same configuration. You would still have a separate retroarch.cfg file for each system as you currently do, so you can control the exact outcome of each system, it is just that when the user wants overlays on NES, then all systems will have overlays. In my opinion this is how I would set it up. It is clean and easy. The end user has 3 choices and running the script is fast and easy, so it isn't like it is that big of an issue to go in and change it.

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

                                  @tmntturtlguy I decided to use 4 options so I could use an overlay with an additional transparent filter which gives a shine or glare on the screen.

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

                                    Can you guys post your scripts on ghostbin (or something similar) instead of meganz? I'm unable to see the script on my phone when it's on meganz.

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

                                      @meleu https://ghostbin.com/paste/ytrxt

                                      It's ... well functional but a huge list with cp commands.
                                      I would prefer your approach as it is the easier way without copy file -->> much better.

                                      @FlashPC
                                      Use submenu and case selection to get it functional calls

                                      Mean...
                                      Main list is SEGA CD -> Select overlay, shader..... for SegaCD

                                      #### THIS IS PSEUDOCODE!!!
                                      
                                      modemenu ()
                                      {
                                      until [[ $shaderchoice == "<--" ]]
                                      do
                                          shaderchoice=$(whiptail --backtitle " Choose " --title " Choose " --menu "Choose an option" 0 0 0 \
                                              "<--" "... back to mainmenu" \
                                              "standard" "Reset retroarch.cfg" \
                                              "shaders" "Use Shaders...." \
                                             .....
                                      done
                                      
                                      case "$shaderchoice" in
                                          standard) cp -f /opt/retropie/configs/all/retroswap/$1/standard/retroarch.cfg /opt/retropie/configs/$1/ ;;
                                          shaders) cp -f /opt/retropie/configs/all/retroswap/$1/shaders/retroarch.cfg /opt/retropie/configs/$1/ ;;
                                      esac
                                      done
                                      }
                                      
                                      #----------------------------
                                      
                                      while true
                                      do
                                          syschoice=$(whiptail --backtitle " Choose " --title " Choose " --menu "Choose an option" 0 0 0 \
                                              "nes" "Nintendo Entertainment System" \
                                              "md" "Sega Megadrive" \
                                             .....
                                      done
                                      
                                      
                                      case "$syschoice"
                                          *) modemenu "$syschoice" ;;
                                      esac
                                      done
                                      
                                      

                                      This will shrink your code to minimum :)

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

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

                                        @meleu https://ghostbin.com/paste/ytrxt

                                        Wow! Pretty huge. It can be simplified, but if it works, then fine. I could help, but it seems to be a very specific script to @FlashPC needs. I'm not sure about the details in his config...

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

                                          Hey guys I've filled in the script that @cyperghost posted and I kind of understand what is trying to happen, but Iam stuck as to what I am missing, I don't know how to add the nice black boxes but I've entered it into ghost paste here

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

                                            https://ghostbin.com/paste/t7ws7

                                            Here is a working script!
                                            As I said --- it's was pseudocode with some errors
                                            2x done without do, break condition was set wrong, dialogboxes showed unneeded options....

                                            If you run this script you will see just 3do standard for ex. as output.. Therefore
                                            You must exchange the commands in line 49-52 with your copy commands.

                                            So you stripped down from 30kB to 3kB and can faster navigate ;)

                                            Greetings fly out to @meleu (<--- this guy is responsible for my rising interest in bash) and @TMNTturtlguy (<--- this guy is responsible that I get in need to use bash ... EUREKA!)

                                            TMNTturtlguyT meleuM 2 Replies Last reply Reply Quote 2
                                            • 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.