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

    [SCRIPT] RetroPie Limit Last Played Games

    Scheduled Pinned Locked Moved Projects and Themes
    shell scriptlast playedgameslimit
    57 Posts 5 Posters 6.6k 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.
    • hiulitH
      hiulit @MadHorse
      last edited by

      @madhorse I found the bug! I'll release a new version with additional functionalities. Maybe tomorrow ;)

      My little contributions to the RetroPie project:

      • Shell-Script-Boilerplate
      • Fun-Facts-Splashscreens
      • Limit-Last-Played-Games
      ClydeC 1 Reply Last reply Reply Quote 0
      • ClydeC
        Clyde @hiulit
        last edited by Clyde

        @hiulit According to @MadHorse's test, the script removed three "last played" occurances, while grep listed four of them in the file. Is that part of the bug, or what else caused the discrepancy? Just mentioning to help you debug. :)

        Ah, just ignore me. The script limited the "last played" to one, thus removed three of four. It's too early here in Germany to write in forums, obviously. 😇

        hiulitH 1 Reply Last reply Reply Quote 0
        • hiulitH
          hiulit @Clyde
          last edited by

          @clyde Almost got it! Been working hard, refactoring stuff :P I guess I'll be releasing a new version soonish.

          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
            MadHorse
            last edited by

            @hiulit @Clyde thank you very much for your help.

            hiulitH 1 Reply Last reply Reply Quote 1
            • hiulitH
              hiulit @MadHorse
              last edited by

              @madhorse whoops, sorry, hehe! You were the one with the issue, actually, and I was replying to @Clyde :P

              My little contributions to the RetroPie project:

              • Shell-Script-Boilerplate
              • Fun-Facts-Splashscreens
              • Limit-Last-Played-Games
              M ClydeC 2 Replies Last reply Reply Quote 0
              • M
                MadHorse @hiulit
                last edited by

                @hiulit said in [SCRIPT] RetroPie Limit Last Played Games:

                @madhorse whoops, sorry, hehe! You were the one with the issue, actually, and I was replying to @Clyde :P

                hehe no problem :)

                1 Reply Last reply Reply Quote 1
                • ClydeC
                  Clyde @hiulit
                  last edited by

                  @hiulit I trust you'll work as hard for @MadHorse as you'd have done for me. ;)

                  hiulitH 1 Reply Last reply Reply Quote 1
                  • hiulitH
                    hiulit @Clyde
                    last edited by

                    @clyde @MadHorse Of course ;) hehe!

                    My little contributions to the RetroPie project:

                    • Shell-Script-Boilerplate
                    • Fun-Facts-Splashscreens
                    • Limit-Last-Played-Games
                    1 Reply Last reply Reply Quote 0
                    • hiulitH
                      hiulit
                      last edited by

                      Here it is!

                      RetroPie Limit Last Played Games v2.0.0

                      Read the new docs, as there have been a few changes.

                      Added

                      • Option to install/Uninstall the script from EmulationStation's RetroPie menu.
                      • GUI mode.
                      • Debug mode - To test the script. No harm will done to the gamelists ;)
                      • Log files - Found in /home/pi/Retropie-Limit-Last-Played-Games/logs).

                      Fixed

                      • Uncommented code preventing to actually remove 'last played' games.
                      • Fixed #1 - Only show systems that have a gamelist.xml.

                      Changed

                      • Refactored the code to create backups. Now the folder is called gamelist-backups (inside the $SYSTEM_ROMS folder) and contains all the game lists backups, named [DATE]-gamelist-backup.xml.
                      • Added more error/success output messages.
                      • Better control of what games have to be processed.

                      Examples

                      ./retropie-limit-last-played-games.sh --nth 25 --systems

                      This will set the number of 'last played' games to limit at 25 and then it will show a dialog from where it can be selected as many systems as needed.

                      ./retropie-limit-last-played-games.sh --nth 25 --systems --debug

                      This will set the debug mode on. It's perfect for testing the script before actually 'harming' the gamelists.

                      ./retropie-limit-last-played-games.sh --gui

                      This will start the GUI. It will ask you to enter a number to limit the number of 'last played' the games shown. Then it will ask you to choose the desired systems to apply that limit.

                      Options

                      • --help: Print the help message and exit.
                      • --install: Install the script in EmulationStation's RetroPie menu.
                      • --uninstall: Uninstall the script from EmulationStation's RetroPie menu.
                      • --nth: Set number of 'last played' games to limit per system (10 by default).
                      • --systems: Show dialog to select systems to limit.
                      • --gui: Start the GUI.
                      • --debug: Set debug mode to test the script.
                      • --version: Show script version.

                      My little contributions to the RetroPie project:

                      • Shell-Script-Boilerplate
                      • Fun-Facts-Splashscreens
                      • Limit-Last-Played-Games
                      ClydeC 1 Reply Last reply Reply Quote 1
                      • ClydeC
                        Clyde @hiulit
                        last edited by

                        @hiulit Great work! (without having tested it)

                        1 Reply Last reply Reply Quote 1
                        • M
                          MadHorse
                          last edited by MadHorse

                          @hiulit, first, thank you so much for your work, your work is really appreciated.
                          Second, yout script is awesome, it's working perfectly.
                          Installed the script on the Retropie menu, launched the script, choosed to keep 1 last played game, at the end of the execution you need to restart Emulationstation to see the results.

                          Now my last played list contain only 40 games, one per system :)

                          Thank you again, you did a great job.

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

                            @hiulit I don't want to do a PR but you can add these lines to perform a restart. You can write a small yes/no dialog to perform a restart to ES.

                            # Restart ES!
                            touch /tmp/es-restart
                            chown pi:pi /tmp/es-restart
                            kill $(pidof emulationstation)
                            

                            Best wishes ;)

                            hiulitH 2 Replies Last reply Reply Quote 1
                            • hiulitH
                              hiulit @MadHorse
                              last edited by

                              @madhorse Hey! You're welcome! I'm glad you find it useful :D

                              And you made a good point about EmulationStation having to be restarted to see the changes. I'll add a message to the script .

                              My little contributions to the RetroPie project:

                              • Shell-Script-Boilerplate
                              • Fun-Facts-Splashscreens
                              • Limit-Last-Played-Games
                              1 Reply Last reply Reply Quote 0
                              • hiulitH
                                hiulit @cyperghost
                                last edited by

                                @cyperghost hey, I was just thinking about adding a message but I like your idea better. Thanks for the code ;)

                                My little contributions to the RetroPie project:

                                • Shell-Script-Boilerplate
                                • Fun-Facts-Splashscreens
                                • Limit-Last-Played-Games
                                1 Reply Last reply Reply Quote 1
                                • hiulitH
                                  hiulit @cyperghost
                                  last edited by hiulit

                                  @cyperghost btw, can this code be run under 'sudo'? Because my script has an option be installed in the RetroPie menu and I think the scripts executed from there are run under 'sudo'.

                                  My little contributions to the RetroPie project:

                                  • Shell-Script-Boilerplate
                                  • Fun-Facts-Splashscreens
                                  • Limit-Last-Played-Games
                                  cyperghostC 1 Reply Last reply Reply Quote 1
                                  • cyperghostC
                                    cyperghost @hiulit
                                    last edited by cyperghost

                                    @hiulit Yes but then the file has to be chowend to pi:pi
                                    Added to the codebox

                                    hiulitH 1 Reply Last reply Reply Quote 1
                                    • hiulitH
                                      hiulit @cyperghost
                                      last edited by

                                      @cyperghost the file being 'tmp/es-restart' or my script?

                                      My little contributions to the RetroPie project:

                                      • Shell-Script-Boilerplate
                                      • Fun-Facts-Splashscreens
                                      • Limit-Last-Played-Games
                                      cyperghostC 1 Reply Last reply Reply Quote 0
                                      • cyperghostC
                                        cyperghost @hiulit
                                        last edited by

                                        @hiulit The restart file
                                        Because ES entitiy deletes the file on restart and if it was created by root it won't work

                                        hiulitH 1 Reply Last reply Reply Quote 1
                                        • hiulitH
                                          hiulit @cyperghost
                                          last edited by

                                          @cyperghost got it. Thanks! 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
                                          • M
                                            MadHorse
                                            last edited by

                                            @hiulit I've found a little "bug", if there are more games that have the exactly same lastplayed it will give you this errore:

                                            Number of 'last played' games to limit is set to '1'.
                                            
                                            psx
                                            ---
                                            'gamelist.xml' for 'psx' found!
                                            > Creating 'gamelist-backups.xml' for 'psx' ...
                                            'gamelist-backups.xml' for 'psx' created successfully!
                                            ./retropie-limit-last-played-games.sh: line 124: [[: 0
                                            1: syntax error in expression (error token is "1")
                                            ./retropie-limit-last-played-games.sh: line 124: [[: 0
                                            1: syntax error in expression (error token is "1")
                                            No 'last played' games to remove.
                                            
                                            All done!
                                            

                                            After i change the time, i just add 1 second, everything is working without a problem.
                                            I think it's almost impossible to have more games with the same lastplayed date and time unless someone manually edit the file and make some mistakes, so probably is not a big deal.

                                            hiulitH 1 Reply Last reply Reply Quote 1
                                            • 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.