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

Multi Switch Shutdown Script!

Scheduled Pinned Locked Moved Ideas and Development
shutdown scriptshutdown switchcyperghost
272 Posts 40 Posters 109.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.
  • C
    cyperghost @Efriim
    last edited by 25 Mar 2019, 10:42

    @Efriim oh yes and even it's not a libRetro core UDP will also fail. You may find a way to send signal level 15 to this core then it will save the day time

    1 Reply Last reply Reply Quote 0
    • E
      Efriim
      last edited by Efriim 31 Mar 2019, 10:06

      @cyperghost said in Multi Switch Shutdown Script!:

      > /dev/null 2>&1

      This broke some things, mostly only the rc.local stopped working. I shouldn't have added it to rc.local, but It worked with rc.local as long as I'm not fumbling around on other things so much.

      C 1 Reply Last reply 31 Mar 2019, 10:13 Reply Quote 0
      • C
        cyperghost @Efriim
        last edited by cyperghost 31 Mar 2019, 10:13

        @Efriim Sorry ... I should think more about next time.
        The output of stdout to /dev/null can't work. Because this output is needed for the python scripts to get response from the script. Maybe just send stderr to /dev/null is better? I did not test so far but I think that makes more sense. Yes, set it for the python script because this causes the error.

        2>/dev/null

        Yes /etc/rc.local is used for the retroflag script for automatic startup. But you can also use autostart.sh from emulationstation. That's the way I prefer...
        You can edit with nano /opt/retropie/configs/all/autostart.sh

        Broken means your installation does not boot anymore? Oh dear, you may edit the file from a second mashine?
        About the commands... please don't forget to add an & at last sign. This will send the process to background otherwise the boot progress stops here.

        E 2 Replies Last reply 31 Mar 2019, 10:27 Reply Quote 0
        • E
          Efriim @cyperghost
          last edited by 31 Mar 2019, 10:27

          @cyperghost
          Thanks. I got the rc.local to work again, I left one of these ">" when I deleted /dev/null.

          When I made reicast from source with /dev/null added to the rc.local I didn't notice any build errors, though when I ran reicast.sh it did give me an error about /dev/null and wouldn't work. I recompiled it and it is not working still. So I guess I was dumb and it had not to do with that.

          I don't know what is up with reicast, the controller used to work without ever setting it up, and then it stopped and the joyconfig didn't work and now the emulator wont even start.

          1 Reply Last reply Reply Quote 0
          • E
            Efriim @cyperghost
            last edited by Efriim 31 Mar 2019, 10:38

            @cyperghost
            Sorry for blaming you. It looked to me that way but I didn't think. They were concatenated in my head as I went from that to this and I apologize.

            The reicast binary installation still works, maybe building has trouble with my environment or maybe it is just broke. The PS3 controller needed to be removed from the bluetooth and resynced because of the alternative driver, it is working again. And now I just might try to add the > /dev/null 2>&1 for the third time.

            On top of that my powersupply was halfway falling out of the surge protector, and I couldn't figure out why I was getting low voltage errors, and I got experimental settings going on with 667 sdram_freq. And I couldn't even think of all the things that can't go wrong with /dev/null.

            Yes the Reicast source is broken and the binary is somewhat broken, there is the older binary in the "working dreamcast games" thread somewhere and I'm using that now. The updated binary works for a while and then crashes on the second round. The errors are a gl get error 0x500 on start and about 15 OMX buffer underruns, which existed with the old version and persist if using "oss"

            I thought about creating a new thread, it will probably get fixed eventually. Or is it more sensible to add to the github?

            C 1 Reply Last reply 31 Mar 2019, 15:11 Reply Quote 2
            • C
              cyperghost @Efriim
              last edited by 31 Mar 2019, 15:11

              @Efriim said in Multi Switch Shutdown Script!:

              Sorry for blaming you. It looked to me that way but I didn't think. They were concatenated in my head as I went from that to this and I apologize.

              There is no need for an apologize, I never felt offended. But nice you sorted this out.

              Maybe you can give feedback how we can get rid off some error messages.

              1 Reply Last reply Reply Quote 2
              • R
                Ranma
                last edited by Ranma 5 Nov 2019, 09:34 11 May 2019, 08:30

                Hi, hope I'm OK asking this here. My Google-fu has failed me, and searching has proved complicated.

                I'm using the Mega-Pi case with your shutdown script and it works brilliantly. However I'd really like to hide the console text on shutdown for cosmetic reasons. I understand that sometimes things go wrong and output is needed when this happens, but I have a backup image and do not intend updating my system. I feel like I've finished my project now and would like to wrap it up with the addition.

                I did find a comment somewhere that suggested to add >/dev/null 2>&1 to /etc/profile.d/10-retropie.sh. I did this and it removed the "terminated 671" line, but the console prompt remains. This is pretty much what displays before shutting down - alt text

                I'd like it to simply go to a black screen if possible before shutting off. If you can help that would be very much appreciated. many thanks.!

                L 1 Reply Last reply 12 May 2019, 04:43 Reply Quote 2
                • L
                  lostless @Ranma
                  last edited by lostless 5 Dec 2019, 05:44 12 May 2019, 04:43

                  @Ranma you need to edit the cmdline.txt file in the /boot directory.
                  I use this for all my pi projects and it hides all text during bootup and shutdown.

                  dwc_otg.lpm_enable=0 console=serial0,115200 console=tty3 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait usbhid.quirks=0x0079:0x1801:0x40 quiet loglevel=3 consoleblank=0 plymouth.enable=0 quiet logo.nologo
                  

                  put it in all as one line.

                  R 1 Reply Last reply 12 May 2019, 10:05 Reply Quote 1
                  • R
                    Ranma @lostless
                    last edited by 12 May 2019, 10:05

                    @lostless Hi thanks for replying. I've already got all that in my cmdline.txt file. I'd already followed a guide to silence the Pi during boot and shutdown, but it doesn't completely work. If I shutdown Retropie via the menu, it's completely quiet, but if I use the button on the Mega-Pi I get the console as above.

                    C 1 Reply Last reply 12 May 2019, 13:09 Reply Quote 1
                    • C
                      cyperghost @Ranma
                      last edited by 12 May 2019, 13:09

                      @Ranma you can try to edit $HOME/.bashrc and play around with it a bit.
                      The reason for showing the terminal is that the multi_switch script terminates ES and you will be set back to terminal. Maybe it helps to just add a clear command at the end of .bashrc

                      R 1 Reply Last reply 12 May 2019, 13:58 Reply Quote 1
                      • R
                        Ranma @cyperghost
                        last edited by 12 May 2019, 13:58

                        @cyperghost Thanks so much for replying. Could I ask, what would be the best way to do this? I can find a number of commands on the internet but I'm not sure of the best one to try. I've been using Linux for some time but never had to edit ./bashrc at any time in the past so my knowledge is non-existent I'm afraid.

                        C 1 Reply Last reply 12 May 2019, 14:20 Reply Quote 0
                        • C
                          cyperghost @Ranma
                          last edited by cyperghost 5 Dec 2019, 15:21 12 May 2019, 14:20

                          @Ranma To be true I have not a real clue about this topic, too. I never ran RetroPie as complete hidden software.
                          Best way to accomplish this task is to use nano $HOME/.bashrc
                          then add clear as last command. This will likely reduce your screen to just the prompt. Maybe @mitu can tell how to redirect the complete terminal tty1 to tty3 or so ;)

                          The clear command gots the advantage that it does not break anything on your current setup. So I consider it as ("breakfail"-)save solution.

                          R 1 Reply Last reply 12 May 2019, 14:44 Reply Quote 2
                          • R
                            Ranma @cyperghost
                            last edited by 12 May 2019, 14:44

                            @cyperghost Excellent, thanks for replying. I added a simple clear at the end of the file and you're right - there's just the login prompt onscreen now. If there's a way to hide that too, that would be even better. Many thanks for your help. :-)

                            R 1 Reply Last reply 17 May 2019, 08:33 Reply Quote 0
                            • M
                              mrnebu
                              last edited by mrnebu 16 May 2019, 11:00

                              @cyperghost hello, i use the nespi+ case, 3b+ but no retropie. the scripts i found so far only work with emulationstation but not if you run console. could you add shutdown now for power and reboot for reset with the led? i tried myself but too much stuff going on in the nespi case for me to finish it within a year and i dont want to mess up your script.

                              would it be possible to add a function in case shutdown is stuck cause no es is running? it could work down other shutdown / reboot options and your script your get even more universal?

                              C 1 Reply Last reply 16 May 2019, 16:38 Reply Quote 0
                              • C
                                cyperghost @mrnebu
                                last edited by cyperghost 16 May 2019, 16:38

                                @mrnebu said in Multi Switch Shutdown Script!:

                                would it be possible to add a function in case shutdown is stuck cause no es is running?

                                That's already possible within the script. For the NESPi+ you see the lines

                                
                                    # Initiate Shutdown per ES
                                    es_action --ES-CLOSEEMU
                                    es_action --ES-POWEROFF
                                
                                    # If ES isn't running use regular shutoff
                                sudo poweroff
                                

                                So indeed if ES is not running it already uses the regular poweroff. On the other hand you can use this script to read status of ES or running emulators and can then decide on your own what to do. So I think it is as flexible as you descripe and will cover a lot of usescases if you know how to use. So I made created a usecase for python here and also RetroFlag mentioned the script.

                                1 Reply Last reply Reply Quote 1
                                • R
                                  Rion @Ranma
                                  last edited by 17 May 2019, 08:33

                                  @Ranma I have been wondering about that to. @mitu Do you have any taughts, ideas?

                                  FBNeo rom filtering
                                  Mame2003 Arcade Bezels
                                  Fba Arcade Bezels
                                  Fba NeoGeo Bezels

                                  mituM 1 Reply Last reply 17 May 2019, 10:47 Reply Quote 0
                                  • mituM
                                    mitu Global Moderator @Rion
                                    last edited by 17 May 2019, 10:47

                                    @Rion said in Multi Switch Shutdown Script!:

                                    taughts

                                    The early bird catches the ... something.

                                    Now, if you want the prompt to disappear and you already modified the .bashrc file, just add as last lines of the file:

                                    export PS1=""
                                    tput civis
                                    

                                    and then logout.

                                    R R 2 Replies Last reply 17 May 2019, 11:42 Reply Quote 3
                                    • R
                                      Rion @mitu
                                      last edited by Rion 17 May 2019, 11:42

                                      @mitu Thank you Mr Bash Shell Wizard!

                                      FBNeo rom filtering
                                      Mame2003 Arcade Bezels
                                      Fba Arcade Bezels
                                      Fba NeoGeo Bezels

                                      1 Reply Last reply Reply Quote 0
                                      • R
                                        Ranma @mitu
                                        last edited by 17 May 2019, 17:16

                                        @mitu I'll add my love here too. This works! Awesome! Thanks so much for replying.

                                        You always know the answer @mitu

                                        Superstar!

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          janderclander14
                                          last edited by janderclander14 6 Aug 2019, 15:21 8 Jun 2019, 14:20

                                          I've modified the python script from this post, which calls the Multiswitch script, to add several reset behaviors with generic buttons connected to the GPIO.

                                          Assuming two buttons, the behavior is as follows:

                                          • One button (connected to GPIO 3) acts as shutdown (and power up)
                                          • The other button resets the system. One short press, quits the current emulator or restarts emulationstation. One long press (3 sec) restarts the system.

                                          I attach here the code just in case someone finds it useful (it assumes multi_switch.sh is in /home/pi). You may add this as a python call to /opt/retropie/configs/all/autostart.sh

                                          #!/usr/bin/env python3
                                          from gpiozero import Button, LED
                                          import os 
                                          from signal import pause
                                          import subprocess
                                          import time
                                          
                                          powerPin = 3 
                                          resetPin = 2 
                                          
                                          resetMinSeconds = 2
                                          
                                          #functions that handle button events
                                          def when_pressed():
                                           output = int(subprocess.check_output(['/home/pi/multi_switch.sh', '--es-pid']))
                                           
                                           if output:
                                               os.system("/home/pi/multi_switch.sh --es-poweroff")
                                           else:
                                               os.system("sudo shutdown -h now")
                                          
                                          def reboot():
                                           start_time=time.time()
                                           diff=0
                                          
                                           while rebootBtn.is_active and (diff < resetMinSeconds):
                                               now_time=time.time()
                                               diff=-start_time+now_time
                                          
                                           output = int(subprocess.check_output(['/home/pi/multi_switch.sh', '--es-pid']))
                                           output_rc = int(subprocess.check_output(['/home/pi/multi_switch.sh', '--rc-pid']))
                                           if (diff > resetMinSeconds):
                                               if output:
                                                   os.system("/home/pi/multi_switch.sh --es-reboot")
                                               else:
                                                   os.system("sudo reboot")
                                           else:
                                               if output_rc:
                                                   os.system("/home/pi/multi_switch.sh --closeemu")
                                               elif output:
                                                   os.system("/home/pi/multi_switch.sh --es-restart")
                                               else:
                                                   os.system("sudo reboot")
                                           
                                          btn = Button(powerPin)
                                          rebootBtn = Button(resetPin)
                                          rebootBtn.when_pressed = reboot 
                                          btn.when_pressed = when_pressed
                                          pause()
                                          
                                          C M 3 Replies Last reply 8 Jun 2019, 21:05 Reply Quote 3
                                          • 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