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

    shell scripting topic

    Scheduled Pinned Locked Moved Ideas and Development
    shellshell scriptprogramming
    191 Posts 10 Posters 88.5k 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 @cyperghost
      last edited by meleu

      @cyperghost There are as many approaches as creativity allows. I just tried to find a way to encompass as many use cases as possible. The explanation for how it works can be complex, but the steps to make it work is not.

      Using an alias has its limitations, but it's an option.

      • 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 Hello brother ;)
        Yes I know it's maybe easy for me and you but take a look here
        https://retropie.org.uk/forum/topic/12930/
        I suggested the first solution (yours)
        but it didn't work, so I used the "old" way.....

        I bought now one of these mausberry devices to test ;)
        It's really hard to test without the device.


        AFAIK an alias can't be called within a script. So you may export the bash function with export -f func_call. But how this works? Do you have a clue?

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

          @cyperghost said in shell scripting topic:

          @meleu Hello brother ;)
          Yes I know it's maybe easy for me and you but take a look here
          https://retropie.org.uk/forum/topic/12930/
          I suggested the first solution (yours)
          but it didn't work, so I used the "old" way.....

          I'll try to find what he made wrong. I think it was my fault: I didn't give really clear instructions for inexperienced Linux users.

          I bought now one of these mausberry devices to test ;)
          It's really hard to test without the device.

          Oh yeah! Let's break that infinite loop!!

          AFAIK an alias can't be called within a script.

          I thought you were talking about creating an alias for shutdown command, making it call the killes.sh script before actually shutdown. But this approach has limitations.

          So you may export the bash function with export -f func_call. But how this works? Do you have a clue?

          When you export something in a shell (functions or variables) only the child shells will know the respective variable/function.

          A good way would be to add this function and the export command to one of these files:

          • ~/.profile
          • ~/.bash_profile
          • ~/.bashrc
          • /etc/profile
          • create a file at /etc/profile.d/ directory (btw, did you notice that you have a /etc/profile.d/10-retropie.sh on your RetroPie? :) )

          But this approach also has its limitations...

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

            I have followed @meleu down the bash rabbit hole and need some help getting out.

            I am trying to write a script for the retropie menu that will allow you to select the overlay you want, (kind of like the SNES Mini). That is where I get stuck.

            My idea is this: When the script starts, it will list all of the overlays in a directory and allow you to select them. Upon selection, it will modify the overlay.cfg file and replace what is there, and finally start the game with the overlay applied.

            Better example of what I am trying to accomplish: https://ghostbin.com/paste/avjcs

            Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

            Backlog: http://backloggery.com/lilbud

            meleuM cyperghostC 2 Replies Last reply Reply Quote 0
            • meleuM
              meleu @lilbud
              last edited by

              @lilbud it's possible. But you have to specify where do you want to apply the overlay (specific for a game? specific for a system?).

              Expand the use case.

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

                @lilbud Yes please - I can't imagine what you exactly want.
                I think it can be wrapped up like here

                1 Reply Last reply Reply Quote 0
                • lilbudL
                  lilbud @meleu
                  last edited by lilbud

                  @meleu The script would apply the overlay to all systems automatically. Individual systems can be modified when launching a game from the system where the user doesn't want an overlay, like GB/GBC/GBA or other hand held systems were aspect ratio is not 4:3

                  @cyperghost Something like that would be nice for this, having the script and be able to choose which systems you want the overlay to be applied to.

                  Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

                  Backlog: http://backloggery.com/lilbud

                  cyperghostC meleuM 2 Replies Last reply Reply Quote 0
                  • cyperghostC
                    cyperghost @lilbud
                    last edited by cyperghost

                    @lilbud automatically means to invoke runcommand-onstart.sh
                    I think it's doable but we need more input about usecase...

                    I think there is a need of 2 parts....

                    1. Part let you choose overlay for special system
                    2. Invokes seleceted overlay to system on start of emulator run

                    I think.... you should start coding. And we will help you ;)
                    You can read the full thread I've posted ... The issue here was solved in an efficient way (imho)

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

                      @lilbud said in shell scripting topic:

                      @meleu The script would apply the overlay to all systems automatically.

                      I'm not sure if an overlay for all systems would look good. I think some systems have a different aspect ratio.

                      As @cyperghost said, we can help you once you start the coding. But maybe the fastest solution is to use rpie-art tool. Learning how to create an info.txt file is faster than learning a programing language.

                      Here is the info.txt creation doc: https://github.com/meleu/rpie-art/blob/master/INFO.md

                      • 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

                        @meleu Yes... therefore the runcommand-onstart. $1 shows current used system. So there is a way to set an overlay for a specfic system ... ;)

                        1 Reply Last reply Reply Quote 0
                        • lilbudL
                          lilbud
                          last edited by

                          @meleu @cyperghost I had this to start with:
                          sed -i 's/01.png/08.png/g' overlay.cfg

                          Something feels missing, not sure what at the moment.

                          Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

                          Backlog: http://backloggery.com/lilbud

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

                            @lilbud where is placed the script with that line of code? maybe you have to use the full path to the overlay.cfg.

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

                              @meleu I believe it is placed in the overlay directory.

                              opt/retropie/configs/all/retroarch/overlay

                              Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

                              Backlog: http://backloggery.com/lilbud

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

                                @lilbud Just start coding use echo commands to show results in your bash
                                You can test sedcommands directly from CLI and results will be marked red.
                                Don't use -i parameter for testing... it will directly write to input file and may give unwantend results. If you want create altered files then work with direction > output-file first.

                                If all works then use -i

                                lilbudL 1 Reply Last reply Reply Quote 0
                                • lilbudL
                                  lilbud @cyperghost
                                  last edited by

                                  @cyperghost Ok, I can get the original command to replace the text, but only if both fields are specified.

                                  sed -i 's/01.png/08.png/g' overlay.cfg

                                  This works fine, 01.png is replaced with 08.png. But what would I put in the first field if the overlay name is not 01.png. Something like this?:

                                  sed -i 's/${FILENAME}.png/08.png/g' overlay.cfg

                                  Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

                                  Backlog: http://backloggery.com/lilbud

                                  mituM cyperghostC 2 Replies Last reply Reply Quote 0
                                  • mituM
                                    mitu Global Moderator @lilbud
                                    last edited by

                                    @lilbud You can use a wildcard:

                                    sed -i 's/.*.png/08.png/g' overlay.cfg
                                    

                                    Note that this will replace any <filename>.png in the file with 08.png.

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

                                      @lilbud I'm still not sure what your goal is.
                                      Anwer yourself:

                                      1. Where is the overlay.cfg located?
                                      2. In which case do you want to alter overlays?
                                      3. Is there a "system" in altering names (Maybe $EMU-$ROMNAME-$TAG.png?)

                                      Imho ... here's is a good script that writes several information in /boot/config.txt and checks existance of data before.

                                      For graphics menu layout you can use this it uses arrays for graphics menu and here is a Howto for dialog/whiptail usage.

                                      Here is the RetroPie wiki and how to input paramters into your script.

                                      lilbudL meleuM 2 Replies Last reply Reply Quote 0
                                      • lilbudL
                                        lilbud @cyperghost
                                        last edited by lilbud

                                        @cyperghost okay

                                        • Overlay.cfg located in default directory, /opt/retrofit/configs/all/retroarch/overlay

                                        • The point of the script is to provide a way a to switch and choose the overlay from the retropie menu in ES.

                                        • So choosing overlay named, '08.png, will do a few things. It will check for an overlay in use. If one is found, then the cfg file will be modified to show the path of the wanted overlay.png, (/my/awesome/overlay/8.png).

                                        • Once the overlay is selected, the main retroarch.cfg will be modified with the viewport settings and the overlay.

                                        Anything else needing further explanation?

                                        Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

                                        Backlog: http://backloggery.com/lilbud

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

                                          @lilbud No I understood.
                                          All the links I've provided to you will help you to code this.
                                          Just start over with the selection menu ;)

                                          lilbudL 1 Reply Last reply Reply Quote 0
                                          • lilbudL
                                            lilbud @cyperghost
                                            last edited by

                                            @cyperghost If I can find a way to get the script done during class, I'll see if I can work on it.

                                            I think there is bash on my school computer...

                                            Creator of the Radiocade: https://retropie.org.uk/forum/topic/6077/radiocade

                                            Backlog: http://backloggery.com/lilbud

                                            cyperghostC 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.