Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first
Can someone modify this script and add a system restart script with it ;)
-
Hi guys,
I'm trying to make 3 buttons on my retropie console, I have already made 2 buttons: these are shutdown button, and reset button that exit emulator.
Here is the script that was used for these 2 buttons ( Thanks to @mitu and @cyperghost ) :
#!/usr/bin/python import RPi.GPIO as GPIO import time import subprocess GPIO.setmode(GPIO.BOARD) shutdownPin=5 resetPin=3 GPIO.setup(shutdownPin, GPIO.IN) GPIO.setup(resetPin, GPIO.IN) oldButtonState1 = True while True: #grab the current button state buttonState1 = GPIO.input(shutdownPin) buttonState2 = GPIO.input(resetPin) # check to see if button has been pushed if buttonState1 != oldButtonState1 and buttonState1 == False: # shutdown subprocess.call("shutdown -h now", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) oldButtonState1 = buttonState1 if not buttonState2: # Reset emulator print "Reset pressed" subprocess.call("/home/pi/scripts/multi_switch.sh --es-closeemu", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) time.sleep(.3)
I want to add to it a restart button that restart the system. Thanks in advance ;)
-
Seems like you know just enough to be dangerous 😜
You can copy and modify your Button1 code, just use "shutdown -r now" instead.
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.