Can someone modify this script and add a system restart script with it ;)
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.
#!/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 ;)
b3k last edited by
Seems like you know just enough to be dangerous 😜
You can copy and modify your Button1 code, just use "shutdown -r now" instead.