gpio-shutdown alternative for LibreElec 8.2.5

  • Update: Starting with LibreELEC (Leia) v8.95.2 BETA it is possible to use dtoverlay=gpio-shutdown. See further down.


    Hi! I felt this area is the most appropriate for what I want to contribute.


    I was searching for a way to shut down my libreelec-Raspberry with the touch of a button wired to pins 5 & 6, as I do for my other raspberrys. Unfortunately the same approch, setting dtoverlay=gpio-shutdown in config.txt didn't work.


    Another solution I found, invoving autostart and a shutdown.sh yielded very strange results in a not-booting raspberry.


    The following approach, seems to work though. Maybe It's not correct so please tell me if I did something wrong.


    First create a file "/storage/.config/gpio-shutdown" with the following content:



    Make it executable with


    Code
    1. chmod +x /storage/.config/gpio-shutdown


    Then create a file "/storage/.config/autostart.sh" (or adjust its content accordingly)


    Code
    1. (
    2. nohup /storage/.config/gpio-shutdown &
    3. ) &


    Make it also executable, then reboot


    Code
    1. chmod +x /storage/.config/autostart.sh
    2. reboot


    How does it work?

    The autostart.sh is invoked every time libreelec is booted. It will then start "gpio-shutdown" in the background. This script will check every second whether or not the GPIO3 is connected to GND. As soon as this is dicovered, a "shutdown -h now" is executed and the raspberry will shut down. You'll see the usuall 10 blinks after which you can disconnect.


    Another touch of the button which connects GPIO3 to GND will boot up your libreelec.

    Edited 3 times, last by Skeeve ().

  • Many thanks for your input - hopefully someone will find it useful.


    I thought the gpio-shutdown worked on 8.2.5 but I could be mistaken. If you have the time, could you test gpio-shutdown on the latest LE alpha build Here Tnx.

  • Yes, the current stable LE still needs scripting to use an on/off button. I did it by calling a Python script. Using the above Shell script works basically the same way. It would be cool to get this function just by setting a "dtoverlay" option. I'll switch to it, when it's part of a stable LE version.


    "dtoverlay=gpio-shutdown" on LE 8.95.002 will let the shutdown menu appear, when pressing the power button. Instant off only works by the described scripting.

    Edited once, last by Da Flex ().

  • Pooling gpio pin every second is probably very bad idea.

    Blu-ray Disc Java menus support - forum thread, Github

    my lamp addon (unofficial/community) (limited no support)
    my touchscreen support and instructions by Grruhn (now touchscreen addon exists in repository)

  • If you have the time, could you test gpio-shutdown on the latest LE alpha build Here Tnx.


    I did and it works. Here is what I did:


    ssh-ed to the system and remounted /flash so that I can change config.txt


    Code
    1. mount -o remount,rw /flash


    Then using my favourite editor (vi) to add the below line to /flash/config.txt below the shown comment.


    Code
    1. ################################################################################
    2. # End of default configuration
    3. ################################################################################
    4. dtoverlay=gpio-shutdown


    Then I've created the file /storage/.kodi/userdata/keymaps/keyboard.xml to contain:


    Code
    1. <keymap>
    2. <global>
    3. <keyboard>
    4. <key id="61662">shutdown</key>
    5. </keyboard>
    6. </global>
    7. </keymap>


    Finally I did a reboot.


    That's it. A button connecting pins 5 & 6 will now shut down your libreelec.

  • "dtoverlay=gpio-shutdown" on LE 8.95.002 will let the shutdown menu appear, when pressing the power button. Instant off only works by the described scripting.

    Thanks to your post and the one by @Iridum I found the solution. Changing the key which is sent helps. See above