Please do not post a support request without first reading and following the advice in

Multi Switch Shutdown Script!

  • @cyperghost

    That’s perfect

    What if I want only poweroff by pressing just once from the power menu?

    I didn’t check @drakaen391 suggestion yet

  • @vivesladron

    What if I want only poweroff by pressing just once from the power menu?

    Not possible - therfore someone has to change the code of EmulationStation.
    You've got the same behaviour with KODI. One file to start but you have to enter the "system" and to start the single "ROM" file ;)

  • @cyperghost
    I'm running the ROMs from a USB drive and I'm having problems with the scripts

    /home/pi/RetroPie/scripts/ line 2 /home/pi/RetroPie/scripts/ Permission denied

    I tried with chmod +x but no difference
    Do you know how to fix it?


  • @vivesladron Shure... just add bash command inside the scripts

    so it will look like
    bash /home/pi/RetroPie/scripts/ --es-restart &

  • @cyperghost

    So easy!
    Thank you!

  • I really appreciate this script and have used it since before I registered to the forums here.

    Since I have had the same retropie build for a while and I uninstalled two or three other shutdown scripts before installing this one.

    I like that I can exit the dreamcast emulator without having to use the controller. I was wondering about when I press the reset button to do this. I get this error:

    rc.local[__]: /opt/RetroFlag/ line 63: kill: (___) - No such process

    Is this normal behavior, and can I fix it?

    I was also wondering about the fan_shutdown additional script.
    When I turn my pi off, say using the Emulationstation menu to shutdown; the fan always stays on until I hit the switch on my case; Was the fan_shutdown script meant to turnoff the fan in that usage? If so what do I need to do to get it to work properly?
    Thanks, @cyperghost

  • @Efriim This could happen if the kill command fails because the PID was closed already and the kill commands leads to a already closed process.
    You can add a > /dev/null 2>&1 to python script in rc.local to get rid of it.

    The fan script is needed for some old NESPi cases. Some users report the fan is still blowing without it. So your description sounds like that it can help in this case. I've a SNES case and I do not need it.

  • @cyperghost
    I think I didn't describe the fan concisely. I was suggesting that the fan should be shutdown with the system e.g. sudo poweroff, and without having to get up and hit the powerswitch. What you say makes sense, that the fan wouldn't shutdown even when hitting the power switch on some cases.
    I have Retroflag MegaPi Case.

  • @Efriim You may add the shutdown script according to the github description

    1. Install fan_shutdown script: cd /lib/systemd/system-shutdown/ && sudo wget && sudo chmod +x shutdown_fan
    2. Install raspi-gpio with sudo apt install raspi-gpio
    3. The shutdown_fan is setted to GPIO4 as standard
    4. Therefore you might edit with sudo nano /lib/systemd/system-shutdown/shutdown_fan

    The script will be executed miliseconds before shutdown and will cut off power and stops the fan from everlasting blowing.

  • I'm trying the different GPIO for the shutdown_fan as it isn't doing anything. I'll update if I am successful. The fan is not connected to the gpio however it is connected to the board that connects to the GPIO. I tried GPIO set 1,2,3,4,5,7,8,10 none did as I wanted it to do. Hitting the powerswitch turns off the fan as per normal.

  • @cyperghost Hi, along with the script and its shutdown function working for dreamcast. A new feature of the reicast emulator is to save the rtc setting to emu.cfg when invoking the exit by pressing the exit hotkey. Using the script reset button to exit the emulator does, so successfully however it doesn't save the rtc settings. Meaning I have the set time/date screen until I make a clean exit with the controller and this lasts for a month or so. Do you think we will be able to add this type of exit to the script for reicast?

    I meant here that the reset button to exit reicast works and I am happy and proud to use this script. If there was a way to passthrough a command to reicast to initialize the poweroff where it saves the rtc, I would too like to know this.

  • Global Moderator

    @Efriim said in Multi Switch Shutdown Script!:

    A new feature of the reicast emulator is to save the rtc setting to emu.cfg when invoking the exit by pressing the exit hotkey

    Are you sure ? The RTC is saved in the NVRAM file (BIOS/dc/dc_nvmem.bin), not in the emu.cfg file.

  • @mitu
    The setting looks like this from emu.cfg
    Dreamcast.RTC = 1543281985

    The nvram needs to be within a number of seconds of this setting, that is why it asks for the time/date even if it has already been saved in the nvram.

  • @Efriim This could happen if the kill command fails. After 2 seconds annother kill command with -9 parameter is send to process and this will terminate the emulator. The only way I see is to use the NET commands retroarch offers. There you can send key commands to proper exit the core. Let me think about it ..,

  • Though it is only with the standalone reicast, indeed. There must be a passthrough to the sdl to initialize the emulator to its shutdown state.

  • @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

  • @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.

  • @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.


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

    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.

  • @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 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.

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.