Author Topic: shutdown from LibreElec / OpenElec  (Read 18040 times)

arjanv

  • NewMember
  • *
  • Posts: 5
  • Country: nl
shutdown from LibreElec / OpenElec
« on: April 02, 2017, 09:12:34 AM »
I'm reading this, but there's no  /home/pi/ folder. Also no /opt/xbmc-bcm/xbmc-bin/share/xbmc/addons/
Can some one help me setting this up for libreelec / openelec?


Using with XBMC
For XBMC you can do it somewhat simpler since there is a shutdown menu which invokes a shutdown command that can be replaced with invoking a custom script. You can use the following equivalent script, save it as /home/pi/softshutdown.sh:

#!/bin/bash
sudo gpio -g mode 10 out;
sudo gpio -g write 10 1;
sleep 4;
sudo gpio -g write 10 0

Next modify this file: /opt/xbmc-bcm/xbmc-bin/share/xbmc/addons/skin.confluence/720p/DialogButtonMenu.xml, and in the "Shutdown description" section replace XBMC.Powerdown() with System.Exec(“/home/pi/softshutdown.sh”).

Naudiz

  • NewMember
  • *
  • Posts: 1
Re: shutdown from LibreElec / OpenElec
« Reply #1 on: July 27, 2017, 03:44:18 PM »
I don't know if you are still searching for a solution, but I stumbled upon your thread while struggling with the same problem and I would like to share my solution.

In this guide I use a modified version of the script, originally intended for Raspian. I place it in /storage/.config/, which is the same place where the OpenElec installscript places the regular shutdowncheck.sh file too, so all ATXRaspi related scripts are in the same place.

Step 1
Create a new file /storage/.config/softshutdown.sh with this content:
Code: [Select]
#!/bin/bash
BUTTON=10

#setup GPIO 10 as output and set to HIGH
echo "$BUTTON" > /sys/class/gpio/export;
echo "out" > /sys/class/gpio/gpio$BUTTON/direction
echo "1" > /sys/class/gpio/gpio$BUTTON/value

#keep GPIO 10 high for at least 4 seconds for shutdown, 1s for reboot (same as pressing ATXRaspi button)
SLEEP=4 #set to 4 for shutdown, set to 1 for reboot.

echo "ATXRaspi button press for: $SLEEP seconds..."

/bin/sleep $SLEEP

#restore GPIO 10
echo "0" > /sys/class/gpio/gpio$BUTTON/value
Step 2
You can skip this step, if you don't want a script for ATXRaspi-Rebooting. I suppose regular rebooting should work fine too, but I never tested it in conjunction with ATXRaspi. IMHO, since we are using an ATXRaspi, it doesn't hurt to handle both shutdowns and reboots through it.
Copy softshutdown.sh to softreboot.sh and modify line 10 to
Code: [Select]
SLEEP=1 #set to 4 for shutdown, set to 1 for reboot.
Step 3
Make the files executable with
Code: [Select]
chmod 777 /storage/.config/softshutdown.sh
chmod 777 /storage/.config/softreboot.sh
    Step 4
    You now need to modify the command from the shutdownmenu of your skin, located in the file DialogButtonMenu.xml. If you use Kodi's default skin, which is "Estuary" in Kodi 17, this file is located in  /usr/share/kodi/addons/skin.estuary/xml/DialogButtonMenu.xml.
    You could directly edit this file, I however prefer a different approach:

    - Download a copy of Estuary from its Github.
    - Look for the file addon.xml
    - In line 2 of this file change id="skin.estuary" to id="skin.estuary.mod" and name="Estuary" to name="Estuary (Mod)"
    - Then edit the file xml/DialogButtonMenu.xml
    - Search for the line <onclick>Powerdown()</onclick>
    - Change it to <onclick>System.Exec("/storage/.config/softshutdown.sh")</onclick>
    - Search for the line <onclick>Reset()</onclick>
    - Change it to <onclick>System.Exec("/storage/.config/softreboot.sh")</onclick>

    Now install your modified version of Estuary, which will now be installed to /storage/.kodi/addons/skin.estuary.mod/. The advantage of this approach is that this skin inside the storage-folder will not be overwritten during ta system update.
    Of course, if you prefer using any other theme you will have to edit its XML similarly.[/list]
    « Last Edit: July 29, 2017, 07:57:05 AM by Naudiz »

    Felix

    • Administrator
    • Hero Member
    • *****
    • Posts: 6866
    • Country: us
      • LowPowerLab
    Re: shutdown from LibreElec / OpenElec
    « Reply #2 on: July 27, 2017, 04:48:46 PM »
    Naudiz, thanks for sharing your solution  ;)