Recalbox Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • recalbox.com
    • Gitlab repository
    • Documentation
    • Discord

    Shutdown Script

    Recalbox General
    script
    6
    25
    8577
    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.
    • Substring
      Substring last edited by

      hey @lackyluuk

      Do you mean you'd like a gpio to be set at UP when shutting down and off once the shutdown procedure is over ? Quite easy to do combining python and some well placed Sxx script :

      1. you need a S99 script which stop parameter would bring that gpio up
      2. you need a S01script which stop parameter would bring that gpio down (despite it would happen anyway by itself as it is shutting down

      Former dev - Please reply with @substring so that i am notified when you answer me
      Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

      1 Reply Last reply Reply Quote 1
      • lackyluuk
        lackyluuk Translator last edited by

        Thank you very much for your answers @acris and @subs.

        Yes this is what I meant @subs. I want to set a GPIO pin to HIGH when the shutdown procedure begins. And as you said I do not need to set it to FALSE again 🙂

        I know where to set startup scripts (init.d), but not where to set shutdown scripts. Could you please help me out? 🙂

        NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

        1 Reply Last reply Reply Quote 0
        • Substring
          Substring last edited by

          @lackyluuk here is a simple example : https://github.com/recalbox/recalbox-buildroot/blob/rb-4.1.X/board/recalbox/fsoverlay/etc/init.d/S25lircd

          All scripts are triggered at start with a start argument, as well as at shutdown with a stopargument.

          A init skeleton script would look like this :

          #!/bin/sh
          
          start() {
          
          }
          
          stop() {
          
          }
          
          case "$1" in
            start)
          	start
          	;;
            stop)
          	stop
          	;;
            restart|reload)
          	stop
          	start
          	;;
            *)
          	echo "Usage: $0 {start|stop|restart}"
          	exit 1
          esac
          
          exit $?
          

          You'd just need to populate the start and stop functions. In your case, the stop function only, and get rid of everything related to start or restart, so after all it would look like this :

          #!/bin/sh
          
          stop() {
          
          }
          
          case "$1" in
            stop)
          	stop
          	;;
          esac
          

          You could even code everything in your stop) case. Now you'd just need to call a python script to raise your gpio output to 1. Call your init.d script something like S99zled so that you're sure it gets called first. The python part should be rather easy, but just say if you need some help.

          Former dev - Please reply with @substring so that i am notified when you answer me
          Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

          1 Reply Last reply Reply Quote 1
          • lackyluuk
            lackyluuk Translator last edited by

            Thank you very much @subs. I will try this.
            With python I do not have any problems 🙂 thank you

            NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

            1 Reply Last reply Reply Quote 0
            • Dragu
              Dragu Banned last edited by Dragu

              @lackyluuk
              I know, is old, this means, you have resolved the case. I would also need such script. I can tell you why. My Nespi near his TV is in a closed case and I always anyway soft shutdown it in ES. After, I have further a remote socket (Is not the only one in this room) to switch it off totaly. So, as I cannot see a modified power led through the shelf door, I want to use a buzzer instead that sounds during the shutdown process. Weird, but are we not here to invent always new perversities ?

              1 Reply Last reply Reply Quote 0
              • Dragu
                Dragu Banned last edited by

                @lackyluuk
                Quelqu'un aurait vu notre ami suisse ?

                Substring 1 Reply Last reply Reply Quote 0
                • Substring
                  Substring @Dragu last edited by

                  @dragu @abunille any news from lackyluuk ?

                  Former dev - Please reply with @substring so that i am notified when you answer me
                  Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                  abunille 1 Reply Last reply Reply Quote 0
                  • abunille
                    abunille @Substring last edited by

                    @substring

                    At the moment very busy. I hope he has more time soon.

                    Wenn ihre Frage beantwortet wurde:
                    Themen-Werkzeuge -> ask as question + Themen-Werkzeuge -> mark as Solved

                    Bei hilfreichen Antworten darf man den jeweiligen Beitrag auch gerne positiv bewerten ;)

                    1 Reply Last reply Reply Quote 0
                    • lackyluuk
                      lackyluuk Translator last edited by lackyluuk

                      @Dragu @Substring I am sorry that I didn't reply. I am still here 🙂 Currently I am quite busy with other things as @abunille said. I really hope that there is more time soon. There is still work to do for the wiki :))
                      @Dragu I think your proposal is possible. Let me check my config (it's a while ago :D) and then I can give you more information 🙂

                      NintendoRS | Nintendo Adapter Box | Cardboard Recalbox

                      1 Reply Last reply Reply Quote 0
                      • Dragu
                        Dragu Banned last edited by Dragu

                        @Substring
                        I tried something out, probably full of errors.
                        I put the stop case in custom.sh together with a call to my other script.

                        #!/bin/bash
                        
                        python /recalbox/share/myscripts/run-fan.py &
                        
                        stop() {
                        python /recalbox/share/myscripts/buzzer.py &
                        }
                        
                        case "$1" in
                          stop)
                        	stop
                        	;;
                        

                        and for the pin that should be high during shutdown (I use 23).

                        #!/usr/bin/env python3
                        import os
                        import signal
                        import sys
                        import RPi.GPIO as GPIO
                        def setup():
                            GPIO.setmode(GPIO.BCM)
                            GPIO.setup(23, GPIO.OUT)
                            GPIO.setwarnings(False)
                            setPin(True)
                            return()
                        try:
                            setup()
                        except:
                            GPIO.cleanup()
                        
                        Substring 1 Reply Last reply Reply Quote 0
                        • Substring
                          Substring @Dragu last edited by

                          @dragu if should rather look like

                          #!/bin/bash
                          
                          stop() {
                          python /recalbox/share/myscripts/buzzer.py &
                          }
                          
                          case "$1" in
                            start)
                              ;;
                            stop)
                          	stop
                          	;;
                          
                          

                          Or you're starting twice your script. I added a start "in case" you'd ever need one for later purpose

                          Former dev - Please reply with @substring so that i am notified when you answer me
                          Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                          1 Reply Last reply Reply Quote 0
                          • Dragu
                            Dragu Banned last edited by

                            @Substring
                            Thanks, but the first line is my fan control, so they cannot be both in custom.sh ?

                            Substring 1 Reply Last reply Reply Quote 0
                            • Substring
                              Substring @Dragu last edited by

                              @dragu add the fan control in the start then

                              Former dev - Please reply with @substring so that i am notified when you answer me
                              Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                              1 Reply Last reply Reply Quote 0
                              • Dragu
                                Dragu Banned last edited by

                                @Substring
                                Good idea, I will try this out tomorrow. 🙂 Have nice dreams . 😉

                                1 Reply Last reply Reply Quote 0
                                • Dragu
                                  Dragu Banned last edited by Dragu

                                  @Substring
                                  J'ai testé, il semble que le script ventilo ne fonctionne pas dans le start().
                                  Quelque part aussi logique, je présume que c'est juste prévu comme runonce, donc scripts qui s'exécutent seulement une fois.

                                  Substring 1 Reply Last reply Reply Quote 0
                                  • Substring
                                    Substring @Dragu last edited by

                                    @dragu custom.sh reçoit start comme paramètre au boot, donc aucune raison que ca ne marche pas

                                    Former dev - Please reply with @substring so that i am notified when you answer me
                                    Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                                    1 Reply Last reply Reply Quote -1
                                    • Dragu
                                      Dragu Banned last edited by

                                      @Substring
                                      Tu sais, parfois ces drôles de machines se fouttent tout simplement de notre gueule 😉

                                      Substring 1 Reply Last reply Reply Quote 0
                                      • Substring
                                        Substring @Dragu last edited by

                                        @dragu nan, c'est toujours du pebkac 😛

                                        Former dev - Please reply with @substring so that i am notified when you answer me
                                        Ex dev - Merci de me répondre en utilisant @substring pour que je sois notifé

                                        1 Reply Last reply Reply Quote 0
                                        • Dragu
                                          Dragu Banned last edited by

                                          @Substring
                                          J'ai compris pepkac est un synonyme d'Ibm 😧

                                          1 Reply Last reply Reply Quote 0
                                          • paradadf
                                            paradadf Staff last edited by

                                            This is an english topic 😉

                                            If your question was answered, please mark it as solved: Topic Tools -> Ask a question + Topic Tools -> Mark as Solved

                                            Dragu 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Want to support us ?

                                            77
                                            Online

                                            99.6k
                                            Users

                                            28.1k
                                            Topics

                                            187.1k
                                            Posts

                                            Copyright © 2021 recalbox.com