[IR PowerButton for RPI] Gracefully shutdown LE with an IR control switch

  • I bought the IR PowerButton for RPI for my Raspberry PI 3 based Kodi player.

    After the hardware install, I went to configure the linux to support it and have the POWEROFF command do a graceful shutdown of the OS instead of a 'crash'.

    Here are the instructions I was given: http://wiki.52pi.com/index.php/Power_But..._set_it_up

    As you can see, they are NOT for LibreElec. Does anyone have reliable instructions on how to get this configured properly for a LibreElec on RPI3 Kodi box?

    Thanks in advance!!!

    • Official Post
    wget http://sprunge.us/MRPN -O /storage/.config/gpioshutdown
    chmod +x /storage/.config/gpioshutdown
    wget http://sprunge.us/MgBZ -O /storage/.config/system.d/powerbutton.service
    systemctl enable powerbutton.service

    ^ The first URL has a slightly cleaned-up version of their gpioshutdown script. The second URL has a complete guess at a systemd.service that runs before Kodi startup. I am a novice at systemd things so no guarantees it will work. I also have no clue what other GPIO dependencies are required for the gpioshutdown script to work. You should consider them as a hint at how to do things; they are likely not a complete solution.

  • I followed your instructions, but it still appears (not sure how to check) to be simply powering off, not gracefully shutting down. The instructions all ran cleanly with no errors, and the two downloaded files look fine.

  • There doesn't appear to be a "standard" way to install the WiringPi library, which this piece of hardware apparently requires.

    I tried downloading the files manually, but the build script uses make, which apparently isn't part of LibreElec either.

    Any help would be very much appreciated!!!

    Surely there is a way to get this remote board working. This is all about Kodi, and Kodi needs to be able to be safely shut down via IR as well as started!

    Thanks again!

  • If this project is really about making a simple-to-use KODI media center, then support for most common remote-on-off board should somehow be possible. I'm extremely frustrated that this OS is SOOOO stripped down, I can't complete the configuration of KODI the way I need it. There should be some way for us to use apt-get.

    Going to a full-blown OS brings along so much crap that I DON'T need that it compromises the "appliance" nature of what we need. However, this OS has gone too far the other way. Please consider adding WiringPi to the image, or else add apt-get so that those of us who know a little can add the components we truly feel we need.

    Thanks much!

  • If it doesn't work (gpio command not found) try adding

    . /etc/profile

    to second line in /storage/.config/gpioshutdown.


  • Well, dang. Still no joy. Hitting the IR power down button still appears to be simply yanking the power, not doing a graceful shutdown.

    The gpio command is definitely working after adding your add-on, so awesome job putting that together!

    Now it's a matter of translating the other bits into their LibreElec equivalents.

    One part I can't quite figure out is what is the LibreElec equivalent of the /etc/rc.local file that is supposed to get these three lines before the exit command that is supposedly already there:

    sudo /etc/init.d/gpioshutdown &

    gpio mode 25 out

    gpio write 25 1

    There is no /etc/rc.local file to put the commands in (yes, I realize I'd need to modify the path in the first line to /storage/.config, which is where the commands in post 3 put it). What is the LibreElec equivalent? Any ideas about that bit?

    I also added these lines to the /flash/config.txt:




    I think part of the problem of troubleshooting this is that when it fails, the power appears to be simply instantly cut off, so you can't see if it got even partway through anything.

    And thanks again!


  • chewitt posted service script as /storage/.config/system.d/powerbutton.service but maybe not working. Let me check it.


  • Could it be that the powerbutton.service is referencing the wrong file? The file references /storage/.config/powerbutton.sh, but there is no such file there with that name. Instead, there is gpioshutdown, which we did set to executable.

    It's definitely an issue, I think, but apparently not the only one still. After fixing and rebooting, it still simply powers down instead of gracefully shutting down.

  • First remove old files

    rm /storage/.config/gpioshutdown
    rm /storage/.config/system.d/powerbutton.service
    rm /storage/.config/system.d/kodi.target.wants/powerbutton.service

    and then try this

    wget http://sprunge.us/LgTH -O /storage/.config/gpioshutdown.sh
    chmod +x /storage/.config/gpioshutdown.sh
    wget http://sprunge.us/hIHa -O /storage/.config/system.d/gpioshutdown.service
    systemctl enable gpioshutdown.service
    systemctl start gpioshutdown.service


  • I've the same issue with 'IR PowerButton for RPI '-shield on my RPi4. With addon 'RPi Tools' and vpeters last workaround it works great.

    Late response, but better as none...;)

    Vielen Dank dafür!