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 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
                  • F
                    FlashPC
                    last edited by FlashPC

                    @cyperghost Thanks, its so tidy

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

                      @flashpc Does it work for you?
                      Can you post the full script with all alterings please?

                      You can even alter the titles and backtitles of each menu for ex. like this --backtitle " Your selected console is ${1^^} " So you have an overview of your systemchoice if you want to exchange the shader. Just a convenient addon...

                      ... There is a small bug Please add a return between line 53 & 54. I update code.

                      What is the difference between overlay and overlay-real?

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

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

                        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!)

                        Greetings back to you @cyperghost! Hope all is well. I just come up with crazy ideas, and pretty down and dirty ways to try to make them work, you and @meleu are the true artists that clean up the messes I start!

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

                          @TMNTturtlguy Yes I'm fine. Thank you - it's always a pleasure to do some coding stuff

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

                            Nice job guys!

                            @cyperghost I would like to recommend this reading when you have a time: Importance of code indentation. ;-)

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

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

                              ... There is a small bug Please add a return between line 53 & 54. I update code.

                              I found that out, does the additional return clear the $shaderchoice variable? I just added "shaderchoice=" at the start of the modemenu routine and that allowed me to select another mode after returning the main screen

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

                              What is the difference between overlay and overlay-real?

                              overlay has side art and a bezel around the screen, overlay-real is the same with an additional semi transparent layer over the play area to mimic sun glare and smears on an old CRT TV

                              The current script is here

                              Thanks again

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

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

                                you and @meleu are the true artists that clean up the messes I start!

                                haha! I tried to be an artist. I even created a blog with some drawings I made: https://meleuartblog.wordpress.com/

                                Stopped updating that 2 years ago...

                                @FlashPC sorry for this off-topic post on your thread. :)

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

                                  @meleu Hehe... I like artists ;)
                                  Drawing is good for relaxing and maybe once a time you come back to design studies. Believe me I've married a talented artist - my wife do great drawings if there is muse. You can do also good scratches with Corel Painter and a small Bamboo Tableu.

                                  Btw.: This one is epic ;)

                                  @FlashPC

                                  I found that out, does the additional return clear the $shaderchoice variable? I just added "shaderchoice=" at the start of the modemenu routine and that allowed me to select another mode after returning the main screen

                                  Yes that also helps, maybe it helps to declare shaderchoice as local variable.
                                  You did a great job ;) Even if the coding is a bit "uncommon" ;) You use tons of if-then clauses to set a variable. Please don't see this as an offence but now you have to maintain two locations of systemnames. It's better to use an array for this and to create the menu out of this, too. But as the script works for you it's okay ....

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

                                    @cyperghost Thanks man, I'm an absolute noob when it comes to this type of coding, I know it's uncommon, but following the information and instructions from various sources I'm finding its a little bit disjointed and I've done some BASIC self training back in the 90s and recently Lua for creating (very simple) programs in windows.

                                    I know of if / then clauses and so it meant I could a load a variable with text depending on the selection. But I want to take this further as a pet project and a learning exercise.

                                    This is how I started with Lua (indigorose auto media studio), I started with a basic idea and then added to it, tidying the code, adding features, and streamlining by searching forums and checking YouTube.

                                    Any learning directions would be definitely be appreciated, I will never be a master but if I could muddle through it would be great

                                    Cheers guys
                                    Paul

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

                                      @flashpc Yes the coding style looks like BASIC... btw - you can install FreeBasic on the Pie and create binaries out of this. So if you want to share your programms the other users don't need an interpreter. So you can stick to any language you want... bash or BASIC.

                                      But I did not know about whiptails --notags command. So your systemlist looks really tidy ;) If you don't like whiptail you can stick to dialog. Dialog is a more expanded box creater as whiptail with much more commands but I prefer whiptail because of it's simply usage.

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

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

                                        But I did not know about whiptails --notags command. So your systemlist looks really tidy ;)

                                        Thanks dude, I found it because I was looking for a way to remove the OK button and read the info for the whiptail command and thought --notags would be interesting.

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

                                          @cyperghost Hey mate, can you please have a look at this as and see if I am on the right track, I am having a go at arrays to tidy the code.

                                          Click here

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

                                            @FlashPC
                                            I think it can be done much easier without in need for a settings variable.

                                            I write some pseudo-code okay

                                            
                                            # Your array
                                            console=("3do" "Panasonic" "nes" "Nintendo Entertainment system"......)
                                            
                                            # Now let whiptail work for you... as it expects two strings for creating text boxes, we give them...
                                            
                                            # I try to use proper indentation for better code reading
                                            # We start our loop for systemchoice here
                                            while true
                                                do
                                                    syschoice=$(whiptail -- back title " Systemmenu ...... \ 
                                                        --nocancel --menu " Choose " \
                                                        "<--" "... back to EmulationStation"
                                                        "${console[@]}" \          # <--- This creates the full menu structure out of array!!
                                                        .... )
                                            
                                                        case "$syschoice" in
                                                            "<--") break ;;
                                                            *) shaderchoice $syschoice ;; # <--- Call to function as in v3 script
                                                        esac
                                                done
                                            

                                            Later you can get real systemname out of array with ${console[$1]} (I hope so) ;)

                                            EDIT:

                                            Add this to function modemenu

                                            local idx=0
                                            until [[ "${console[idx]}" == "$1" ][
                                                do
                                                   idx=$(( $idx + 1 ))
                                                done
                                            

                                            Then use whiptail and higher idx+1 and you've the console name... That's it and it was funny ;)

                                            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.