Modify a safe shutdown script.
-
@cyperghost I'll apologize in advance because I'm just starting to learn Linux, so I feel like a middle school kit at Harvard.
Does that disable the Reboot and shutdown menu's in Emulation station itself?
Is it possible to run es-shutdown from an external script, in essence shutting down emulation station in the same way that emulation station shuts down the pi?
My guess would be to replace the "sudo shutdown -h now" with "./path-to/es-shutdown"?
If I understand, and removing es-shutdown prevents someone from exiting emulationstation from the menu, that may come in handy for my arcade, but I wasn't planning on disabling it for now.
My goal is to dissect their script so I understand it better, and possibly modify it to shut down the RetroPie more safely.
-
@sixspeeddeath said in Modify a safe shutdown script.:
Does that disable the Reboot and shutdown menu's in Emulation station itself?
No ... it doesn't touch anything on the Graphic-Shutdown-menu
Is it possible to run es-shutdown from an external script, in essence shutting down emulation station in the same way that emulation station shuts down the pi?
Yes you can run the script from a external script. You can also modify the script and can path parameters to it.... like
./es_action.sh shutdown
to shutdown the Pie
or./es_action reboot
to Reboot the Pie or just./es_action quites
to terminate ES and go back to terminal.My guess would be to replace the "sudo shutdown -h now" with "./path-to/es-shutdown"?
No just erase that line. ES itself gots a little script that watches for action according to files placed in temp-folder. With
touch
you set a access date to a file. If the file is not available it will be created. It's better then to redirect likeecho > /tmp/es_shutdown
If you start the script with
/path/to/es_shutdown.sh
the Pie will shutdown withsudo poweroff
command hence to the explaination hereMy goal is to dissect their script so I understand it better, and possibly modify it to shut down the RetroPie more safely.
You can play arround with the script and learn some bash scripting. It isn't so difficult. Don't worry! And welcome to RetroPie
-
@cyperghost @mediamogul, I REALLY want to thank you for all your help.
I'm trying to change careers to Linux admin, and the RetroPie has been my "Carrot" for learning the OS.
Gradually, I'm picking the stuff up, but responses with information like what is supplied here do more than help me get a toy working, it's something I plan to use for the rest of my life.
I can only Bury my nose in a CompTIA book for so long before I need some hands on, and this is exactly what I needed.
Thank you.
-
Glad it worked out for you.
-
So, I love Python over Bash...
but I cant convert one over the other....
Any Ideas how to convert this to python?
-
@mediamogul I am using the original safe shutdown part...
import RPi.GPIO as GPIO import os import time ###look at the GPIO for the Button Switch to be depressed GPIO.setmode(GPIO.BCM) GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.wait_for_edge(3, GPIO.FALLING) def main(): while True: es-close() def es-close(): os.system("/etc/killes.sh") while True: print((es-close)) time.sleep(1) os.system("shutdown now")
and a very slightly modded es shutdown code
#!/bin/bash ############################## #This Script was created by # #meleu on the retropieforums.# ############################## # Check if EmulationStation is running. Finish the script if doesn't. espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")" || exit 0 # the "sed" command below isn't a crypted message :), it's just a trick to # make $emucall regex-safe to use in the "pgrep -f" below. emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)" # If there's an emulator running, we need to kill it and go back to ES if [[ -n "$emucall" ]]; then emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')" kill "$emupid" wait "$emupid" sleep 0.5 fi kill "$espid" wait "$espid" sleep 0.5
-
I'm not understanding how or where to fix the problem of the kintaro 9000 case not saving metadata.
Pi Model or other hardware: Pi 3b
Power Supply used: 5.1v 2.5a
RetroPie Version Used: 4.3.17
Built From: Pre made SD Image on RetroPie website, updated to 4.3.17
USB Devices connected: dongle for wireless keyboard
Controller used: Official PS3 Controller -
@quackwalks Do you by chance have a large number of roms scraped?
-
@drakaen391 I do have a large number of roms scraped.
-
@quackwalks that could be the issue, increase the wait time a few seconds because emulationstation takes more time to save the meta data if there are alot of scrapped roms
-
@drakaen391 said in Modify a safe shutdown script.:
increase the wait time a few seconds
A static wait time really isn't a good idea for something like this. If you use something similar to the while statement in my example above, it will always take as as much time as it needs, no matter what the circumstances.
-
@drakaen391 About your posted codings.... Does the wait command works in your case? @mediamogul and his while-loop by monitoring PID status is imho better ...
wait can only be used on child processes out of the own subshell
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.