So in Raspian i managed to add a switch to a GPIO port and a python script to shutdown or restart the Pi. I found a script that worked and then modified it to suit my needs.
- Code: Select all
sudo apt-get install python-dev
sudo nano /home/pi/offswitch.py
Then paste in the following text:
- Code: Select all
from time import sleep
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(25,GPIO.IN,pull_up_down=GPIO.PUD_UP)
btn_timer=0
while True:
if ( GPIO.input(25) == False ) :
btn_timer = btn_timer+1
else:
if ( btn_timer > 5 ) :
os.system('sudo shutdown -h now &')
elif (btn_timer > 2) :
os.system('sudo reboot &')
elif (btn_timer > 0.5) :
os.system('sudo ifup wlan0 &')
btn_timer = 0
sleep(0.5);
CtrlX to save and exit
- Code: Select all
sudo chmod -x offswitch.py
sudo python /home/pi/offswitch.py
The possibilities could be extended based on the duration of button press to activate other commands like restarting the wireless controller as per my last command. Now in the Runeaudio build I am struggling to know how I could implement the same procedure. Could someone please advise if the python install and script above would still work, the locations to install, etc?