[How to] Pimoroni OnOff SHIM with LibreELEC

  • I have been able to install the Pimoroni OnOff SHIM on my RPi running LibreELEC. The OnOff SHIM enables you to completely power off - and power on again - a Raspberry Pi with a single pushbutton. As mentioned elsewhere in this forum, it is not possible to install it using Pimoroni's install script, as this requires use of apt-get to install packages, which is not available under LibreELEC; also, it would be necessary to change paths throughout the script.

    I came across this thread on the Retropie forum, where the author had stripped this down to two simple shell scripts. Inspired by this, I have created the following scripts for LibreELEC.

    The first is a python script, which checks for the button being pressed, and if held for > 1 second (as with the Pimoroni script), invokes the halt (or poweroff) os command. This requires the Raspberry Pi Tools add-on, and should be called from autostart.sh. (I saved it in /storage/.kodi/userdata.)

    The second script, which is called as part of the shutdown process, will flash the SHIM's onboard LED 3 times, and then drive GPIO 4 low, cutting the power to the RPi (as with the Pimoroni script):

    This needs to be saved as /storage/.config/shutdown.sh

    Now, pressing and holding the button - or calling 'Power off system' from the Power options menu, will completely power off the RPi.

    A momentary press of the button will power it up again.