XBMC: Difference between revisions

896 bytes added ,  6 years ago
m (m)
Line 114:
 
<br />
 
 
== LibreElec Shutdown Button ==
 
 
https://forum.libreelec.tv/thread/1754-problem-installing-pi-tools-addon/
 
Raspberry Pi Tools
 
 
/storage/.config/shutdown_pi.py
 
#!/bin/python
import RPi.GPIO as GPIO
import time
import os
import sys
 
sys.path.append("/storage/.kodi/addons/virtual.rpi-tools/lib")
 
# Use the Broadcom SOC Pin numbers
# Setup the Pin with Internal pullups enabled and PIN in reading mode.
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down = GPIO.PUD_UP)
# Our function on what to do when the button is pressed
def Shutdown(channel):
os.system("sudo shutdown -h now")
# Add our function to execute when the button pressed event happens
GPIO.add_event_detect(3, GPIO.FALLING, callback = Shutdown, bouncetime = 2000)
# Now wait!
while 1:
time.sleep(1)
 
 
/storage/.config/autostart.sh
 
#!/bin/bash
(
/storage/.config/shutdown_pi.py
)&