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 113.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.
    • BiZzAr721B
      BiZzAr721 @cyperghost
      last edited by BiZzAr721

      @cyperghost Looking forward to giving it a try this evening. I'll edit this post with the results.

      EDIT:
      I recompiled GPIO-Halt, and pointed the script to your script. It worked great!
      @cyperghost I appreciate all I have learned from you since the OpenBOR days lol What you do here for the community is a beacon of your character. Not only are you always willing to help, but you also take the time to explain and help others improve their skills.

      It may not be much, but I thought it to be rewarding to fork the Adafruit Gpio-halt git, and compile it (and have it work!).

      Thanks!

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

        @BiZzAr721 Thanks you for your kindly words but I also asked question regarding coding in the beginning and @meleu helped me a lot, too.

        BiZzAr721B 1 Reply Last reply Reply Quote 0
        • BiZzAr721B
          BiZzAr721 @cyperghost
          last edited by

          @cyperghost Is always great to have a community of likeminded people who share a common interest, be it skydiving, retro gaming, or whatever. You end up with a diverse group of people with various skills all sharing ideas & talents, which usually transcends beyond political or religious differences.

          1 Reply Last reply Reply Quote 1
          • M
            mth75 @janderclander14
            last edited by

            @janderclander14 said in Multi Switch Shutdown Script!:

            ne 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

            This was next on my list :-) ...

            1 Reply Last reply Reply Quote 0
            • y-elloY
              y-ello
              last edited by

              Does it work with Raspberry Pi 4?

              quicksilverQ 1 Reply Last reply Reply Quote 0
              • quicksilverQ
                quicksilver @y-ello
                last edited by

                @y-ello yes it does, I'm using it with my pi4 in the argon one case.

                I QuackwalksQ 2 Replies Last reply Reply Quote 1
                • I
                  Initial_G @quicksilver
                  last edited by

                  @quicksilver said in Multi Switch Shutdown Script!:

                  @y-ello yes it does, I'm using it with my pi4 in the argon one case.

                  Hi @quicksilver, I was looking to set this up when my Argon one arrives.

                  I wanted to ask, could you share how you have your setup? from your above comment
                  https://retropie.org.uk/forum/topic/17415/multi-switch-shutdown-script/207

                  • did you just install the power button/fan script from Argon one?
                    & then just modify the argononed.py to something like:
                    os.system("reboot") -> os.system("bash /path/to/multi_switch/multi_switch.sh --es-reboot")
                    os.system("shutdown now -h") -> os.system("bash /path/to/multi_switch/multi_switch.sh --es-poweroff")

                  • is anything else needed?

                  Thx!

                  quicksilverQ 1 Reply Last reply Reply Quote 1
                  • quicksilverQ
                    quicksilver @Initial_G
                    last edited by quicksilver

                    @Initial_G that's exactly what I did. Just make sure the multi switch script has the proper permissions as well.

                    On a side note (not related to the shutdown script) I also used the fan speed utility script to adjust when the argon one case fan turned on. I found it turned on at too low of a temp and I set it so that it wouldn't turn on unless it got to 65c. I prefer passive cooling as much as possible and only want fan as a last resort. Even with my pi overclocked the fan almost never needs to come on.

                    I 2 Replies Last reply Reply Quote 1
                    • I
                      Initial_G @quicksilver
                      last edited by

                      @quicksilver said in Multi Switch Shutdown Script!:

                      @Initial_G that's exactly what I did. Just make sure the multi switch script has the proper permissions as well.

                      On a side note (not related to the shutdown script) I also used the fan speed utility script to adjust when the argon one case fan turned on. I found it turned on at too low of a temp and I set it so that it wouldn't turn on unless it got to 65c. I prefer passive cooling as much as possible and only want fan as a last resort. Even with my pi overclocked the fan almost never needs to come on.

                      Cool thx for the quick reply, I think I'll update the fan temps too :)

                      1 Reply Last reply Reply Quote 0
                      • I
                        Initial_G @quicksilver
                        last edited by Initial_G

                        @quicksilver

                        did you have to update the pulsetimes in the argononed.py?
                        as a test I changed:

                        	if pulsetime >=2 and pulsetime <=3:
                        		#os.system("reboot")
                        		os.system("bash /home/pi/RetroPie/scripts/multi_switch.sh --es-restart")
                        	elif pulsetime >=4 and pulsetime <=5:
                        		#os.system("shutdown now -h")
                        		os.system("bash /home/pi/RetroPie/scripts/multi_switch.sh --es-reboot")
                        

                        so I can trigger the ES restart with double tap but whenever I try to hold for 3s, it seems to just poweroff, instead of triggering the reboot from multi_switch (which I've tested ok when I made the double tap trigger it). So now I've just left the double tap of the power button to do a reboot

                        Ideally I'd like someting along the lines of:
                        double tap: ES restart
                        hold for 3-5s: reboot
                        hold for 10s: power off

                        quicksilverQ 1 Reply Last reply Reply Quote 1
                        • quicksilverQ
                          quicksilver @Initial_G
                          last edited by

                          @Initial_G I didn't play with the pulse times, but if you get that part of it working the way you like it id be interested as well.

                          RionR 1 Reply Last reply Reply Quote 1
                          • QuackwalksQ
                            Quackwalks @quicksilver
                            last edited by

                            @quicksilver I'm also curious to know what steps I should take to have a proper power button and fan with the argon one case.

                            quicksilverQ 1 Reply Last reply Reply Quote 0
                            • quicksilverQ
                              quicksilver @Quackwalks
                              last edited by

                              @Quackwalks place the multi_switch.sh on your pi somewhere like /home/pi/RetroPie/scripts/multi_switch.sh and make sure it has executable permissions. Then modify your argononed.py script (im assuming you have already installed the default argon one script) located at usr/bin/argononed.py and look for this section and modify it to look like this:

                              if pulsetime >=2 and pulsetime <=3:
                              		#os.system("reboot")
                              		os.system("bash /home/pi/RetroPie/scripts/multi_switch.sh --es-restart")
                              	elif pulsetime >=4 and pulsetime <=5:
                              		#os.system("shutdown now -h")
                              		os.system("bash /home/pi/RetroPie/scripts/multi_switch.sh --es-reboot")
                              

                              The fan script utility is installed and can be modified using the booklet instructions that came with your argon one. I cant find my instructions so youll have to look that up.

                              QuackwalksQ 1 Reply Last reply Reply Quote 2
                              • QuackwalksQ
                                Quackwalks @quicksilver
                                last edited by

                                @quicksilver You are awesome.

                                1 Reply Last reply Reply Quote 1
                                • RionR
                                  Rion @quicksilver
                                  last edited by

                                  @quicksilver said in Multi Switch Shutdown Script!:

                                  @Initial_G I didn't play with the pulse times, but if you get that part of it working the way you like it id be interested as well.

                                  Yea me to. 😊

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

                                  1 Reply Last reply Reply Quote 0
                                  • AshpoolA
                                    Ashpool
                                    last edited by Ashpool

                                    A general thanks to the folks having an Argon1 and who are tinkering with the argon script to call cyberghosts one!

                                    But I still have some questions: The Argon1 Manual says for action Long Press >=5s the Function is a Forced Shutdown, as this is working even without installing the script, my assumption is: a >=5sec Press simply cuts the power and doesn't provoke any script (So nothing of the save stuff-things, that a controlled shutdown from cyberghosts script will be invoking is performed) :( Inside the argononed.py I cannot even find anything that can be configured 'bout the >=5sec timing.
                                    So, I will state two hypotheses I want to have clarified:
                                    a) a correct shutdown (writing Meta Stuff/etc.) with cyberghosts script would mean something like this

                                    os.system("bash /home/pi/RetroPie/scripts/multi_switch.sh --es-poweroff")
                                    

                                    b) a shutdown via the Argon1 Case Button with a press >=5sec is, from within a running system, a worst case scenario as it just cuts the power. So a regular Emulationstation Shutdown should be used instead (If the 3-5sec press is used for a restart)?

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

                                      @Ashpool You should use a correct name to tag me ;)
                                      Nevertheless, I don't own a ArgoneOne. But there is a small IC that is attached to I2C-bus on this housing. AFAIK it writes only two values to the flash, one for a reboot and one for shutdown. So the case "knows" how to enable/disable the power source.

                                      So you are correct - by using the multi_switch call you can perform a save shutdown but the long press action with the sudden power cut is performed by the ARGON ONE hardware. No chance to change anything with a simple script.

                                      You can take a look to BATOCERA - here the script was modified to perform some more actions. Take a look at the script here

                                      RionR 1 Reply Last reply Reply Quote 1
                                      • RionR
                                        Rion @cyperghost
                                        last edited by

                                        @cyperghost is correct. Sadly without re flashing the IC there is nothing we can do.

                                        I more in depth explanation can be found here by Spiros Papadimitriou.

                                        Read under hardware protocol.

                                        Maybe something can be learned from Spiros Papadimitriou rewrite of the script?

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

                                        1 Reply Last reply Reply Quote 1
                                        • AshpoolA
                                          Ashpool
                                          last edited by Ashpool

                                          @cyperghost & @Rion
                                          Thanks for the confirmation that the forced shutdown truly is "hardwired". And the GitHub Link to Spapadim was interesting to read (besides (sorry can't restrain myself here) that he is getting milliseconds wrong). Especially this part is something that I hadn't considered as a possibility so far:

                                          After a "shutdown" request, the board will wait for a brief period of time and then cut off power anyway. Therefore, it is critical that the system shutdown command is issued ASAP. Unfortunately, it seems that this poweroff delay is hardcoded into the board's firmware.
                                          If your shutdown sequence takes longer than 1-2sec (e.g., if you mount network drives that need to be flushed and umounted, for instance), it would be better to avoid using the case's power button to initiate a shutdown.

                                          As I am, at the moment, away from home during the next week, i cannot check the time for multiswitch.sh shutdown on my setup & if maybe the only safe way to perform a shutdown via multiswitch.sh initiated by the argon1 script would be using the double tap call (Edit: At least that would take away the 21..22..23...(24.25)...counting fear)

                                          P.S.: At least for my retroflag cases (Raspi3B(+)) multiswitch.sh is still in the "sliced bread"-(of usefulness)-league ;)

                                          1 Reply Last reply Reply Quote 0
                                          • IdelacioI
                                            Idelacio
                                            last edited by

                                            I've installed the script on the NESPi 4 case set up with Retropie on an SSD.

                                            And they work... mostly. One issue though:

                                            When switching off the device correctly shuts down the OS and then... stays on. Lights off etc but the fan is still spinning. I can;t switch it back on from this state either, have to unplug from the power and plug back in.

                                            Something similar happens with the Retroflag scripts, only with those it will boot back up again immediately after shutting down the OS without me doing anything.

                                            Now all this said I should point out that I'm running a 512GB SSD from the USB2 slot so that may be causing issues? Pi 4 just flat out won't boot anthing above a 256GB 2.5" SSD from USB3... I've had no issues through USB2 though.

                                            Any solutions to this issue?

                                            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.