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

Added Kodi (LibreElec) support #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,22 @@ Example for RecalBox:
5. In the terminal, type the one-line command below(Case sensitive):

wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/recalbox_install.sh" | bash

--------------------

Example for Kodi (LibreElec):

**Method A (via ssh):**
1. Get your raspberry IP: Settings > Sytem Information > Network
2. Connect via ssh from your computer: `ssh root@<your-ip-address>`. Default password is `libreelec`
3. Copy&Paste the command below:

`wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/libreelec_install.sh" | bash`

**Method B (directly to your raspberry)**
1. Make sure internet and keyboard are connected.
2. Press CONTROL+ALT+F3 to enter the terminal.
3. User:root Password:libreelec
4. In the terminal, type the one-line command below(Case sensitive):

`wget -O - "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/libreelec_install.sh" | bash`
45 changes: 45 additions & 0 deletions libreelec_SafeShutdown.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import sys

# Point out to the library location
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib/')
from gpiozero import Button, LED
import os
from signal import pause

# GPIO Settings
powerPin = 3
resetPin = 2
ledPin = 14
powerenPin = 4
hold = 1

# Main LED on
led = LED(ledPin)
led.on()

# Power LED on
powerLED = LED(powerenPin)
powerLED.on()

# Functions that handle button events
def pressed():
led.blink(.2,.2)
os.system("systemctl stop kodi && sleep 5s && shutdown -h now")
def released():
led.on()
def reboot():
os.system("systemctl stop kodi && sleep 5s && reboot")

# Define buttons
powerButton = Button(powerPin, hold_time=hold)
rebootButton = Button(resetPin)

# Map actions
rebootButton.when_pressed = reboot
powerButton.when_pressed = pressed
powerButton.when_released = released

# Keep waiting for a button signal
pause()

63 changes: 63 additions & 0 deletions libreelec_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash


#Step 1) remount /flash as writtable------------------------
mount -o remount,rw /flash
echo "Remounted /flash as writtable"

#Step 2) enable UART----------------------------------------
cd /flash/
File=config.txt
if grep -q "enable_uart=1" "$File";
then
echo "UART already enabled. Doing nothing."
else
echo "enable_uart=1" >> $File
echo "UART enabled."
fi

#Step 3) Download & rp-tools (includes gpiozero)------------
echo "Downloading rpi-tools..."
cd /storage/.kodi/addons/
wget http://addons.libreelec.tv/8.2/RPi2/arm/virtual.rpi-tools/virtual.rpi-tools-8.2.104.zip

#Step 4) Install--------------------------------------------
echo "Installing rpi-tools..."
unzip virtual.rpi-tools-8.2.104.zip
rm virtual.rpi-tools-8.2.104.zip
chmod +x /storage/.kodi/addons/virtual.rpi-tools/bin/*

#Step 5) Download Python script-----------------------------
echo "Downloading python script..."
cd /flash/
script=libreelec_SafeShutdown.py

if [ -e $script ];
then
echo "Script libreelec_SafeShutdown.py already exists. Doing nothing."
else
wget "https://raw.githubusercontent.com/RetroFlag/retroflag-picase/master/libreelec_SafeShutdown.py"
fi
#-----------------------------------------------------------

#Step 6) Enable Python script to run on start up------------
echo "Enabling autostart..."
cd /storage/.config/
echo "python /flash/libreelec_SafeShutdown.py &" >> autostart.sh
echo "Added to autostart"
#-----------------------------------------------------------

#Step 7) Reboot to apply changes----------------------------
echo "RetroFlag Pi Case installation done. Will now reboot after 3 seconds."
sleep 3
sudo reboot
#-----------------------------------------------------------