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.4k 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.
    • RionR
      Rion @AndersHP
      last edited by

      @cyperghost Is it possible to make this work with the Argon One case?

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

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

        @Rion scroll up a few posts ;)

        https://retropie.org.uk/forum/topic/17415/multi-switch-shutdown-script/207

        1 Reply Last reply Reply Quote 2
        • BiZzAr721B
          BiZzAr721
          last edited by

          Hello @cyperghost! Hope all has been well, or as well as it can be with this COVID-19 paranoia. I decided to make a mini arcade using an AdaFruit Arcade Bonnet and a Raspberry Pi 3 B+. I am using a generic momentary pushbutton. I can not get the shutdown script AND the arcade bonnet controls to work at the same time. It seems having raspi-gpio installed blocks the controller inputs (which are mapped to keyboard buttons). Key presses work on a keyboard but not while passing through the arcade bonnet.

          The arcade bonnet has breakouts to gpio pins. I tried GPIO 3, which is used by the arcade hat, but I also tried other GPIO pins that are not used by the hat. Here is a link to info and pictures of the board.

          During install there is an option to install a gpio-halt utility. I've tried both with and without to no avail. I uploaded the contents of the arcadebonnet.pyand rc.local files. Here is the Adafruit-GPIO-Halt git.
          arcadebonnet.py
          rc.local

          I am wondering if it could be possible to redirect gpio-halt to your shutdown script. I just flashed an SD card with a clean retropie image, so I can start again with a new install.
          Thanks, and stay well.

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

            @BiZzAr721 Yes ...
            https://github.com/adafruit/Adafruit-GPIO-Halt/blob/master/gpio-halt.c#L261
            change here the call to script and then compile.

            All is well, thank you :)

            1 Reply Last reply Reply Quote 1
            • BiZzAr721B
              BiZzAr721
              last edited by

              I never did get to learn how to compile like I wanted to. Is there something in a gpio-halt script that can manually edit after it is installed? I'm not even fully understanding how to change the call to script before compiling. Sorry for being a bother.

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

                @BiZzAr721 You just change the line

                (void)system("shutdown -h now");
                

                to annother call. I would use annother script.

                (void)system("/home/pi/RetroPie/shutdown.sh");
                

                Then you create annother script /home/pi/RetroPie/shutdown.sh and make it executable with chmod +x /home/pi/RetroPie/shutdown.sh. Then you can nest any command as you like inside this. After this code change you compile as Adafruit descripes. I'm sure you do not need to stick to this specific C-program. The same can be achived in python.

                Imho you can use multi_switch.sh --generic powerbtn=21 call to achive same funtion. But I can't test this. Please use sudo apt raspi-gpio before.

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

                  I created a fork of Adafruit-GPIO-Halt. I made the change to (void)system("/home/pi/RetroPie/shutdown.sh");

                  I'm confident I can compile it from there. Should I put a call to multi_switch.sh --generic powerbtn=21 in the script or should I call to it directly before compiling?
                  There is a call in rc.local to /usr/local/bin/gpio-halt 6 & (6 being the gpio pin used, which can be changed)
                  If I set it to gpio 2 SDA or gpio 3 SCL, arcade controls will not work. Maybe that explains why raspi-gpio causes loss of controls. (Is it possible to get raspi-gpio to not monitor those pins?)

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

                    @BiZzAr721 I think it works with multi_switch.sh --generic powerbtn=21 and you do not need the Adafruit-GPIO-Halt.

                    If you compile the source code now with your changes you can add ANY command to the script you've created. Then you can just add path/to/multi_switch.sh --es-poweroff

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