Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we have a script for LibreELEC? #137

Open
danielristic opened this issue Oct 27, 2022 · 1 comment
Open

Can we have a script for LibreELEC? #137

danielristic opened this issue Oct 27, 2022 · 1 comment

Comments

@danielristic
Copy link

LibreELEC is also a very popular OS to install on a Raspberry PI and it does not seem there is a simple way to set up safe shutdown on it with a RetroFlag case.

@MikeBergmann
Copy link

MikeBergmann commented Mar 28, 2024

Installation on LibreELEC is straightforward:

  • Install the pi-tools add-on via LibreELEC GUI to get RPi.GPIO
  • Follow dtbo installation from install script:
    File=/boot/config.txt
    wget -O "/boot/overlays/RetroFlag_pw_io.dtbo" "$SourcePath/RetroFlag_pw_io.dtbo"
    if grep -q "RetroFlag_pw_io" "$File";
    then
    sed -i '/RetroFlag_pw_io/c dtoverlay=RetroFlag_pw_io.dtbo' $File
    echo "PW IO fix."
    else
    echo "dtoverlay=RetroFlag_pw_io.dtbo" >> $File
    echo "PW IO enabled."
    fi
    if grep -q "enable_uart" "$File";
    then
    sed -i '/enable_uart/c enable_uart=1' $File
    echo "UART fix."
    else
    echo "enable_uart=1" >> $File
    echo "UART enabled."
    fi
  • Copy https://github.com/RetroFlag/retroflag-picase/blob/master/SafeShutdown.py to /storage/.config/RetroFlag folder
  • Patch the script with the patch below.
--- /home/mibergmann/Downloads/Mike/Retroflag/SafeShutdown.py
+++ /media/mibergmann/STORAGE/.config/RetroFlag/SafeShutdown.py
@@ -1,6 +1,8 @@
+import sys
+sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib/')
 import RPi.GPIO as GPIO
 import os
 import time
 from multiprocessing import Process
 
 #initialize pins
@@ -20,41 +22,32 @@
 	GPIO.output(powerenPin, GPIO.HIGH)
 	GPIO.setwarnings(False)
 
 #waits for user to hold button up to 1 second before issuing poweroff command
 def poweroff():
 	while True:
-		#self.assertEqual(GPIO.input(powerPin), GPIO.LOW)
 		GPIO.wait_for_edge(powerPin, GPIO.FALLING)
-		os.system("sudo killall emulationstation")
-		os.system("sudo killall emulationstatio") #RetroPie 4.6
-		os.system("sudo sleep 5s")
-		os.system("sudo shutdown -r now")
+		os.system("shutdown -h now")
 
 #blinks the LED to signal button being pushed
 def ledBlink():
 	while True:
 		GPIO.output(ledPin, GPIO.HIGH)
-		#self.assertEqual(GPIO.input(powerPin), GPIO.LOW)
 		GPIO.wait_for_edge(powerPin, GPIO.FALLING)
 		start = time.time()
 		while GPIO.input(powerPin) == GPIO.LOW:
 			GPIO.output(ledPin, GPIO.LOW)
 			time.sleep(0.2)
 			GPIO.output(ledPin, GPIO.HIGH)
 			time.sleep(0.2)
 
 #resets the pi
 def reset():
 	while True:
-		#self.assertEqual(GPIO.input(resetPin), GPIO.LOW)
 		GPIO.wait_for_edge(resetPin, GPIO.FALLING)
-		os.system("sudo killall emulationstation")
-		os.system("sudo killall emulationstatio") #RetroPie 4.6
-		os.system("sudo sleep 5s")
-		os.system("sudo shutdown -r now")
+		os.system("shutdown -r now")
 
 
 if __name__ == "__main__":
 	#initialize GPIO settings
 	init()
 	#create a multiprocessing.Process instance for each function to enable parallelism 
  • Add the following autostart.sh file to /storage/.config/
(
  /usr/bin/python /storage/.config/RetroFlag/SafeShutdown.py
)&

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants