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

    Restart ES via bash script!

    Scheduled Pinned Locked Moved Help and Support
    restartemulationstatio
    13 Posts 5 Posters 3.7k 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.
    • cyperghostC
      cyperghost
      last edited by cyperghost

      Dear user the feature richest version is here posting #6 - please use this!


      Edit: abolished version (yet functional)

      Edit: lazy way pkill -n emulationstatio
      works exactly as the script ... just kills the latest process of ES

      KEEP CARE! You have to use touch /tmp/es-restart before using the restart commands!

      The trick is do not to kill all childs. I think it has something to do with the SDL framework.

      Create file home/pi/RetroPie/retropiemenu/Restart ES.sh
      copy code in
      make it executable, Restart ES manually via menu (hopefully last time)
      Then Restart ES is selectable via RetroPie Menu

      That was really hard to resolve!

      #!/bin/bash
      # by cyperghost
      # 06/16/2017
      # That was rocking hard!
      echo "Create es-restart"
      sudo touch "/tmp/es-restart"
      echo "Kill latest process PID of ES"
      sleep 3
      kill $(pgrep -l -n emulationstatio | awk '!/grep/ {printf "%s ",$1}')
      sudo rm -f "/tmp/es-restart"
      
      TMNTturtlguyT 1 Reply Last reply Reply Quote 1
      • BuZzB
        BuZz administrators
        last edited by

        Was there a need for that language ?

        To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

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

          @cyperghost awesome! Do I have your permission to add this code into my script for each of the Es change functions? I don't see the need for this in the retropie menu but rather right within my script for my use case. Thanks for figuring this out so quickly!

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

            @BuZz No, but this drive me nuts .... I knew there is a solution!

            • I listed the cpp code of ES
            • watched services from RetroPie
            • listed bash scripts from ES
            • ...and yes ES checks for the existance of empty description files

            So my first intension not to kill all child processes was 100% right but then I looked to @TMNTturtlguy script and in the file '/usr/bin/emulationstation' is the path to victory :)

            Next time I use "EUREKA", right?

            @TMNTturtlguy of course you can use this in your script. Just write a small contribution within. But please be aware of future changes in ES.

            I'm very thankfull for your attempts because I asked me why you want to create empty files. But they are important for the boot staring progress.

            Again: Please take care of future version. This script just kills the latest PID of ES!

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

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • cyperghostC
                cyperghost
                last edited by cyperghost

                New coder new solution - @BuZz created a nice two liner

                RetroPie-setup 4.2.8 needed (released 06/16/2017)

                #!/bin/bash
                #Restart ES via Bash script v1.1
                #06/16/2017 v1.0
                #intensive rework done by BuZz all greetings fly out to him
                #special thank to @TMNTturtlguy  for bug hunting!
                #version 06/17/17 slightly modified by meleu
                touch /tmp/es-restart
                pkill -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)"
                

                It was tested several times by @BuZz @TMNTturtlguy and myself.

                How to:
                Copy this script to /home/pi/RetroPie/retropiemenu/´ Create bash file like Restart ES`there
                Give file permission and user pi:pi 755



                Attention: RetroPie-setup < 4.2.8 (realease date 06/16/2017) should use sudo -u pi touch /tmp/es-restart

                That resolves problems with data permission!

                Source:
                https://retropie.org.uk/forum/topic/11043/how-to-restart-es-from-a-script/73

                BuZzB 1 Reply Last reply Reply Quote 0
                • BuZzB
                  BuZz administrators @cyperghost
                  last edited by BuZz

                  @cyperghost with the latest retropie-setup you can remove the sudo -u pi btw.

                  To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

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

                    done

                    BuZzB 1 Reply Last reply Reply Quote 0
                    • BuZzB
                      BuZz administrators @cyperghost
                      last edited by

                      @cyperghost (retropie-setup 4.2.8)

                      To help us help you - please make sure you read the sticky topics before posting - https://retropie.org.uk/forum/topic/3/read-this-first

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

                        @BuZz clearly written!
                        Made Bash rework

                        pi@retropie:~ $ touch /tmp/es-restart
                        pi@retropie:~ $ pkill -f -e "/opt/retropie/supplementary/.*/emulationstation$"
                        emulationstatio killed (pid 999)
                        

                        Only one PID killed! Three alive!

                        1 Reply Last reply Reply Quote 0
                        • paffleyP
                          paffley
                          last edited by

                          Hi,

                          Sorry I know this is an old thread but thought it was relevant to my question :)

                          Currently using 4.4

                          My script below, it works fine but it outputs:

                          rm: cannot remove '/tmp/es-restart': Operation not permitted

                          Script

                          #!/usr/bin/env bash
                          rm /opt/retropie/configs/all/emulationstation/es_settings.cfg
                          cp /opt/retropie/configs/all/emulationstation/emulationstation_swap/megadrivejapanmini/es_settings.cfg /opt/retropie/configs/all/emulationstation/ 
                                  echo -e "\n\n\n                               Theme set to: Mega Drive Japan mini\n\n\n"
                          
                          sudo touch "/tmp/es-restart"
                          sleep 3
                          kill $(pgrep -l -n emulationstatio | awk '!/grep/ {printf "%s ",$1}')
                          sudo rm -f "/tmp/es-restart"
                          

                          I currently have it to swap out the es_settings.cfg file but going to adapt it to search es_settings.cfg for the actual text command and change on the fly but for now I'm just trying to see what the options are for restarting ES after the first initial command has been activated.

                          Would just like to know if there is a new approach to restarting es without the use of es-restart ?

                          mituM 1 Reply Last reply Reply Quote 0
                          • mituM
                            mitu Global Moderator @paffley
                            last edited by

                            @paffley You should start a new topic.

                            paffleyP 1 Reply Last reply Reply Quote 0
                            • paffleyP
                              paffley @mitu
                              last edited by

                              @mitu said in Restart ES via bash script!:

                              @paffley You should start a new topic.

                              Thanks @mitu I solved my problem so no need to start a new topic. I also changed from rm/cp to the grep command to edit the existing es_settings.cfg

                              I did the above so I could change themes from within the retropie system whilst in Kiosk mode, also have done the same for screen ratio's and overlays :)

                              Cheers!

                              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.