Emulationstation Shutdown Script
Would anyone happen to know where I can find the script that is called when shutdown is selected within emulationstation? I figured it might be somewhere in the emulationstation install directory, but I'm not quite sure where that might be on the Raspberry Pi. Any help would be greatly appreciated.
@GaM3r2Xtreme i think it's called natively through the emulationstation binary (I may be wrong). You can use
sudo killall emulationstationin a bash script to kill it though.
PaulCheffus last edited by
One the Quit menu are the following selecitons:
Quit Emulationstation works fine to close the program, but the other three do not. They all close out emulationstation, but restart will not work and the over all system will not shutdown or restart. I'm curious to see what script is being called when each is picked so I might be able to edit it and correct the issue.
Hopefully its not in built directly in the program binary, otherwise it might be harder to edit.
emulationstation.shseems to be located in
/usr/bin/. I believe your talking about the command executed within the bash window. If so, I currently have this as the script:
#!/bin/bash if [[ $(id -u) -eq 0 ]]; then echo "emulationstation should not be run as root. If you used 'sudo emulationstation' please run without sudo." exit 1 fi if [[ "$(uname --machine)" != *86* ]]; then if [[ -n "$(pidof X)" ]]; then echo "X is running. Please shut down X in order to mitigate problems with losing keyboard input. For example, logout from LXDE." exit 1 fi fi clear tput civis "/opt/retropie/supplementary/emulationstation/emulationstation.sh" "$@" reset
The script in
/opt/retropie/supplementary/emulationstation/emulationstation.shlooks like the following:
#!/bin/sh esdir="$(dirname $0)" while true; do rm -f /tmp/es-restart /tmp/es-sysrestart /tmp/es-shutdown "$esdir/emulationstation" "$@" [ -f /tmp/es-restart ] && continue if [ -f /tmp/es-sysrestart ]; then rm -f /tmp/es-sysrestart sudo reboot break fi if [ -f /tmp/es-shutdown ]; then rm -f /tmp/es-shutdown sudo poweroff break fi break done
I wonder if the shutdown has something to do with the second script. Any ideas?
meleu last edited by
@GaM3r2Xtreme The script makes me believe that ES creates these files at some poin of its lifetime:
Translating the script to english:
es-restartexists, it restarts ES only. If doesn't exists...
es-sysrestartexists, it restart the system. If doesn't exists...
es-shutdownexists, it turn off the system, If doesn't exists...
finish the script.
So, I think that your emulationstation is failing in creating those files at
/tmp. Check if those files exist while ES is running.
PaulCheffus last edited by PaulCheffus
The second script is the one I was meaning. The shutdown and restart commands from the quit menu are processed by that script. If you want to test it remove the sudo reboot from the above script then select restart from the menu. Nothing should happen.
So I was able to figure out when
Right after bootup, these files are nonexistent. I ran an SSH connection and started up emulationstation, after which checking the
/tmp/directory and concluding that the files still have not been created. Instead, the moment I choose a quit option from the Quit menu, a corresponding temp file is created.
Each selection creates the following:
"Restart Emulationstation" creates
"Restart System" creates
"Shutdown System" creates
"Quit Emulationstation" creates nothing
I'm curious to see if those if statements are correctly written within the above scripts, as it appears that the
/opt/retropie/supplementary/emulationstation/emulationstation.shnear the end right after the
tput civisline. If they are incorrect, then the default will always be to break out of the while loop and end everything, ignoring anything selected in the Quit menu.
Although, the second script may not be executing at all. I've noticed that all the temp files stay around after every restart of emulationstation.
rm -f /tmp/es-restart /tmp/es-sysrestart /tmp/es-shutdownis called right before the emulationstation binary is called, which should delete anything that exists in the
/tmp/folder before emulationstation starts. Maybe there is some sort of write protection going on that prevents this command from executing. This is all so confusing...
May I ask, does anyone else have this shutdown/restart issue as well? Do these Quit commands work ok for others? If so, are you using one of the pre-made RetroPie images or was retropie build via the github page?
meleu last edited by
May I ask if you are using one of the pre-made RetroPie images or build it via the github page?
Try to describe your environment in details.
I should have added this to the end of my last post.
I'm currently using the DietPi v136 OS, which is a bare-bone Raspbian distribution. I'm using this in order to limit background processes and maximize processing towards emulating. Plus, I can fit all that I need on a 2GB card.
Right after flashing the OS onto a card, I followed the manual installation from the wiki in order to install Retropie from the github repository. I've gone through the setup and installed all the core packages, along with a limited amount from the main packages. Everything works great, and games run fine. It's just the shutdown causing issues I'd like to understand.
There might be some write protections going on within the OS. If that's the case, I'll contact the forum group over there and see if they might have some insight.
But first, I'll see about modifying the scripts and throw a few echos around to see what might be happening. I will also try one of the pre-made images and also building from github onto a Raspbian image.
meleu last edited by meleu
@GaM3r2Xtreme my first shoot would be in
Oh, I just found something @meleu. Apparently when I type just emulationstation within the terminal and hit enter,
/usr/bin/emulationstationis NOT called, but something else is.
Now if I force the terminal to execute
/usr/bin/emulationstaitonand then select one of the Quit options, it works. I successfully rebooted the system.
Let me check and see what is in the
/etc/sudoers. I should note that DietPi normally runs under the root user (there is no pi user setup by default).
which emulationstation. Note you won't benefit from any better performance running dietpi. Just more likely to have compatibility issues.
Please check the link in my signature when asking for help as it saves time if we have all the information about your setup.
Adding the extra line of code within
/etc/sudoersdidn't seem to do the trick, but thanks for the suggestion to check it out.
I did use
which emulationstationwhich returned
/usr/bin/emulationstation. The funny thing is that
/opt/retropie/supplementary/emulationstation/emulationstationis executed directly instead via the
emulationstationcommand, but not the
/user/bin/emulationstation. This is all based on what I see in the resource monitor
Would it be possible to change what file is executed with the
emulationstationcommand? If so, I would think this would be the solution I'm after.
On a side note, I'll make sure to post system information if I have any other issues and open another thread.
Yes, if you find out why that is being launched directly - the which command shows which is being launched if you just type in emulationstation unless there is a system alias in place - type
/usr/bin/emulationstationshould just be a script which launches
/opt/retropie/supplementary/emulationstation/emulationstation.shwhich in turn launches
If there is an alias - it must be added by dietpi and you should report the issue there - dietpi is not officially supported by retropie.
I just saw the thread you have over at the dietpi forums. I see from their code, they are launching is incorrectly at startup. They also do set an alias
You will need to ask them to change this. I can't really help if they are not using our launch scripts.
I think you found the issue @BuZz. And yeah, I started a thread with dietpi awhile back and revived it to point out what was found here. I suggested a solution to their auto start script, but never noticed the system alias you found. Both might need a little tweaking, but that's up to those guys if they want to do this.
As far as I'm concerned, a solution was found for the issue I was having. Thanks again for all the help everyone.
backstander last edited by
I am curious about your custom EmulationStation.sh script to shutdown using your ATXRasPi PCB. I have some old power/reset switches that came out of some old PCs and I currently have 1 switch to turn on & off my Pi (gracefully) and I have a 2nd switch I want to use to restart ES (and maybe a 3rd one to exit the currently running emulator). Could you post your script because I'm not sure exactly how I was going to do the ES restart code.
PaulCheffus last edited by PaulCheffus
The script doesn't use extra buttons as it is for shutting down from the emulationstation menu. It requires a bc337 transistor and a 1k resistor with the emitter and collector of the transistor connected across the existing switch. The 1k resistor goes between one of the GPIO pins and the base of the transistor.
When I have the laptop out next I'll post the scripts.
makaveeti last edited by
Has anyone figured out how to get the shutdown system option working from windows version of ES?