• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
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 76.2k 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.
  • H
    hiulit @cyperghost
    last edited by hiulit 21 Feb 2018, 18:35

    @cyperghost Yeah, thanks! I've been following the thread ;) I'll dig in when I have the time. Good job!

    My little contributions to the RetroPie project:

    • Shell-Script-Boilerplate
    • Fun-Facts-Splashscreens
    • Limit-Last-Played-Games
    1 Reply Last reply Reply Quote 1
    • M
      meleu @cyperghost
      last edited by 22 Feb 2018, 11:01

      @cyperghost I strongly recommend you to take a look at @hiulit 's work on the retropie-shell-script-boilerplate.sh (I believe he would give this input also). I also worked on that template.

      I was about to submit a new PR when I realized that you would take some advantage looking at that code. ;-)


      @hiulit what do you think about focusing on aspect ratio instead of trying to detect the exact resolution?

      • Useful topics
      • joystick-selection tool
      • rpie-art tool
      • achievements I made
      H C 2 Replies Last reply 22 Feb 2018, 11:53 Reply Quote 1
      • H
        hiulit @meleu
        last edited by 22 Feb 2018, 11:53

        @meleu Hey sorry, yeah, maybe you're right! But then, should I have a predefined resolution? Like 1080p, 720p, 800x600 and let the user decided which size to use?

        My little contributions to the RetroPie project:

        • Shell-Script-Boilerplate
        • Fun-Facts-Splashscreens
        • Limit-Last-Played-Games
        M 1 Reply Last reply 22 Feb 2018, 13:23 Reply Quote 0
        • M
          meleu @hiulit
          last edited by meleu 22 Feb 2018, 13:23

          @hiulit said in shell scripting topic:

          should I have a predefined resolution?

          I'm not confident enough to say what you should do :), but I can say what I do on my launching image generator tool.

          I'm currently away from my dev machine to confirm, but IIRC the command below is what you need to resize an image to a height of 576 pixels. The resulting_image's width will be the one necessary to keep the same aspect ratio of the original_image.

          convert -resize x576 original_image resulting_image
          

          EDIT: confirmed. The command above works exactly as I described.

          By the way, I noticed you're commiting experimental stuff (such as this resolution thing you were discussing above) directly on the master branch of the fun-facts repo. This is NOT a good practice. ;-)

          • Useful topics
          • joystick-selection tool
          • rpie-art tool
          • achievements I made
          H 1 Reply Last reply 23 Feb 2018, 08:29 Reply Quote 0
          • C
            cyperghost @meleu
            last edited by 22 Feb 2018, 17:27

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • C
              cyperghost
              last edited by cyperghost 22 Feb 2018, 17:30

              @meleu Yes I used your function call. Works nice.
              Is there anything against the return $value method?
              Or am I abusing the being of $? as method to check if a function/command gave return code =0 for okay and !=0 for errors?

              So thx... pushed BashROMManager to v080 now.
              Do you have any suggestion in the use of xmlstarlet or better use grep?

              Maybe the script can be extended to clean also image-files and videos related to it - version 2.x?

              1 Reply Last reply Reply Quote 0
              • H
                hiulit @meleu
                last edited by 23 Feb 2018, 08:29

                @meleu Yeah! I know! I should've created a new branch for this new feature.. :P But It is safe to use master because I made the code backwards compatible, so nothing that was already there is broken and the new things aren't even documented yet. When using git for yourself (at least for me) you tend to use bad practices because it's easier, hehe!

                A part from that, I see you point of just using height to maintain the aspect ratio, but I don't know how can I can create images for different resolutions that will look good on every device. I mean, if I use, let's say, the 576px you said, it will look too small on a 1920x1080 screen, I think. I'll give it a try anyway to see how "bad" (or good!) it looks. Thanks, as always! ;)

                My little contributions to the RetroPie project:

                • Shell-Script-Boilerplate
                • Fun-Facts-Splashscreens
                • Limit-Last-Played-Games
                M 1 Reply Last reply 23 Feb 2018, 09:18 Reply Quote 0
                • M
                  meleu @hiulit
                  last edited by 23 Feb 2018, 09:18

                  @hiulit said in shell scripting topic:

                  I don't know how can I can create images for different resolutions that will look good on every device. I mean, if I use, let's say, the 576px you said, it will look too small on a 1920x1080 screen, I think

                  My tool generate launching images with 576 pixels height and keep the aspect ratio of the image being used as background, Rokkervik's pixel-themed launching images are 480x272. All of them looks just fine on my 1920x1080 TVs...

                  If you create launching images 1920x1080 the resulting file can be very big and the raspberry pi can delay to display a big image

                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  H 1 Reply Last reply 23 Feb 2018, 09:24 Reply Quote 1
                  • H
                    hiulit @meleu
                    last edited by 23 Feb 2018, 09:24

                    @meleu Yeah, you're right. Pixel theme images look fine on my 1920x1080 monitor. I'll try it! ;)

                    My little contributions to the RetroPie project:

                    • Shell-Script-Boilerplate
                    • Fun-Facts-Splashscreens
                    • Limit-Last-Played-Games
                    1 Reply Last reply Reply Quote 0
                    • H
                      hiulit
                      last edited by 6 Mar 2018, 14:53

                      I've created this little script to format all theme.xml from a given EmulationStation theme with 4 spaces. It's really unnecessary, but I'm that kind of person :P

                      Here it goes:

                      #!/usr/bin/env bash
                      
                      THEME="pixel"
                      
                      for folder in "/etc/emulationstation/themes/$THEME/"*; do
                          if [[ -d "$folder" ]]; then
                              if [[ -f "$folder/theme.xml" ]]; then
                                  cp "$folder/theme.xml" "$folder/theme-backup.xml"
                                  xmlstarlet fo -s 4 "$folder/theme.xml" > "$folder/theme-indent.xml"
                                  sed -i '/\?xml/d' "$folder/theme-indent.xml"
                                  cp "$folder/theme-indent.xml" "$folder/theme.xml"
                                  rm "$folder/theme-indent.xml" "$folder/theme-backup.xml"
                              fi
                          fi
                      done
                      

                      My little contributions to the RetroPie project:

                      • Shell-Script-Boilerplate
                      • Fun-Facts-Splashscreens
                      • Limit-Last-Played-Games
                      1 Reply Last reply Reply Quote 1
                      • H
                        hiulit
                        last edited by 8 Mar 2018, 09:30

                        When you have a dialog inside a dialog inside a dialog (and so on...), can the "Cancel" button act as a "Back" button? I know the label can be changed, but when you click it it goes back to the first dialog :(

                        My little contributions to the RetroPie project:

                        • Shell-Script-Boilerplate
                        • Fun-Facts-Splashscreens
                        • Limit-Last-Played-Games
                        M 1 Reply Last reply 8 Mar 2018, 23:48 Reply Quote 0
                        • M
                          meleu @hiulit
                          last edited by meleu 3 Aug 2018, 23:50 8 Mar 2018, 23:48

                          @hiulit there's no "dialog inside a dialog". You execute a dialog and when you choose the "OK" or "Cancel" button the dialog finishes.

                          What causes that impression of a "dialog inside a dialog" is usually a dialog being called one right after another, each one inside its own while loop structure.

                          The example I have to show is one of my codes that I am least proud of when it comes to well-written code, but well, let's try...

                          Check the rpie-art code here: https://github.com/meleu/rpie-art/blob/master/rpie-art.sh

                          This while loop in main_menu() contains the first dialog. Depending on the option, the script calls another function which has another dialog. Let's follow the uninstall_art_menu() flow.

                          When the user choose X on the main_menu(), the script calls the uninstall_art_menu() function which has another dialog where you can:

                          1. Choose Cancel: the logic flow returns to main_menu() and that loop calls the main_menu()'s dialog again.
                          2. Choose a valid option. Which calls another function which has another dialog and the chain-of-dialogs goes on...

                          Eh... I'm not sure if I explained well. 😅

                          Read, check the code and reread. If you still don't understand feel free to ask. ;-)

                          • Useful topics
                          • joystick-selection tool
                          • rpie-art tool
                          • achievements I made
                          H 1 Reply Last reply 12 Mar 2018, 08:25 Reply Quote 1
                          • H
                            hiulit @meleu
                            last edited by 12 Mar 2018, 08:25

                            @meleu Thanks! That's what I thought. I'll create some functions then, as you did ;)

                            My little contributions to the RetroPie project:

                            • Shell-Script-Boilerplate
                            • Fun-Facts-Splashscreens
                            • Limit-Last-Played-Games
                            1 Reply Last reply Reply Quote 0
                            • H
                              hiulit
                              last edited by 4 Apr 2018, 14:09

                              Hi there!
                              Can somebody help me figure this out?

                              I have an argument passed to a shell script fun-facts-splashscreens.sh --create-fun-fact that can have:

                              • no options
                              • 1 option [system]
                              • 2 options [system rom]

                              How can I write a help message? --create -fun-fact [] [system] [system rom]?

                              Thanks!

                              My little contributions to the RetroPie project:

                              • Shell-Script-Boilerplate
                              • Fun-Facts-Splashscreens
                              • Limit-Last-Played-Games
                              mituM 1 Reply Last reply 4 Apr 2018, 14:33 Reply Quote 0
                              • mituM
                                mitu Global Moderator @hiulit
                                last edited by 4 Apr 2018, 14:33

                                @hiulit Add a -h option and display the help when this option is passed to the script.

                                H 1 Reply Last reply 4 Apr 2018, 14:51 Reply Quote 0
                                • H
                                  hiulit @mitu
                                  last edited by 4 Apr 2018, 14:51

                                  @mitu I'm sorry, I didn't explain myself clearly enough.

                                  I already have a -h option that shows all the options available. What I meant is, how should I tell the user that the option --create-fun-fact can have:

                                  • no options
                                  • 1 option [system]
                                  • 2 options [system rom]

                                  That's what I've come up with: --create-fun-fact [] [system] [system rom]
                                  Is that correct?

                                  Did I explain myself better this time? :P

                                  My little contributions to the RetroPie project:

                                  • Shell-Script-Boilerplate
                                  • Fun-Facts-Splashscreens
                                  • Limit-Last-Played-Games
                                  mituM M 2 Replies Last reply 4 Apr 2018, 14:57 Reply Quote 0
                                  • mituM
                                    mitu Global Moderator @hiulit
                                    last edited by 4 Apr 2018, 14:57

                                    @hiulit said in shell scripting topic:

                                    --create-fun-fact [] [system] [system rom]

                                    Ah, ok. I think the correct syntax would be

                                    --create-fun-fact [SYSTEM] [ROM]
                                    

                                    Usually an argument in brackets ([arg]) means the argument is optional.

                                    H 1 Reply Last reply 4 Apr 2018, 14:59 Reply Quote 0
                                    • H
                                      hiulit @mitu
                                      last edited by 4 Apr 2018, 14:59

                                      @mitu I see! And if an argument is NOT optional? I have some of those around :P

                                      My little contributions to the RetroPie project:

                                      • Shell-Script-Boilerplate
                                      • Fun-Facts-Splashscreens
                                      • Limit-Last-Played-Games
                                      mituM 1 Reply Last reply 4 Apr 2018, 16:15 Reply Quote 0
                                      • mituM
                                        mitu Global Moderator @hiulit
                                        last edited by 4 Apr 2018, 16:15

                                        @hiulit If it's not optional, just remove the brackets.

                                        --create-fun-fact system [rom]
                                        
                                        1 Reply Last reply Reply Quote 0
                                        • M
                                          meleu @hiulit
                                          last edited by meleu 4 Apr 2018, 20:12 4 Apr 2018, 16:57

                                          @hiulit can you explain the use case and provide some examples?

                                          I'm sure we can find ways to make an option have zero, one or two options, but from a user point of view I think it's a bit confusing.

                                          EDIT:
                                          I can't see what would be the use for --create-fun-fact system rom, but if it's intended to be used on RetroPie, you can detect the system by looking the directory where the rom is located.

                                          • Useful topics
                                          • joystick-selection tool
                                          • rpie-art tool
                                          • achievements I made
                                          H 1 Reply Last reply 5 Apr 2018, 09:00 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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received