Shutdown on single button press

  • Hi All,

    I am looking to use a Raspberry Pi3B+ in my car. I have designed and built a circuit that handles the power management and am using gpio-shutdown and gpio-poweroff dtoverlays, which seem to be doing what they are supposed to (they are now included in the LE9 test builds) , other than one thing...

    When I use the gpio that I have assigned to shutdown, I get the shutdown dialog come up. Usually this would be fine, but I want it to actually shutdown, not prompt to ask me to do it.

    I assume basically what I am wanting to do is to actually shutdown on a single keypress. is this something that can be done easily - Its probably more of a Kodi question rather than Libreelec but thought I would try here first.


    Thanks

    • Official Post

    I've used gpio-shutdown on Raspbian without issues - I would firstly only use the shutdown overlay as both together may be conflicting. Also by using the standard default setup of GPIO 3 - gpio-shutdown allows a boot by toggling the GPIO again.

    I'll try tomorrow to see what the issue is, as it should shutdown the RPi without intervention (Well that's my interpretation of the driver) . Maybe some dev rule is forcing this to display the shutdown menu instead of a poweroff.

  • HI,

    Thanks for the replies. I thought I needed the poweroff overlay also, as this pin stays high whilst the RPi is running and then goes low on shutdown - I use this to switch power off once the RPI has shutdown.

    I will give the keyboard.xml modification a try and see if that works.


    Thanks for the help so far, this is the last niggle I need to sort before I can install it in the vehicle.

  • I've been having a play - and this might work for you.

    Install Raspberry Pi tools add-on in LE Repository.

    Create /storage/.config/autostart.sh

    Code
    (
    python /storage/off-button.py
    ) &

    Save and make executable chmod +x autostart.sh (Obviously change location to where you'll keep your scripts)

    Create /storage/off-button.py (This is based on dtoverlay-shutdown using GPIO 3)

    Reboot and a hard switch will poweroff the RPi within 5/10 seconds

  • It looks like all gpio-shutdown does is send the keystoke "KEY_POWER" to Kodi - which is what you are seeing with the shutdown menu. So it looks like the remapping is the best solution.

    gpio-poweroff doesn't seem to be implemented (yet).

    Wierd really, as its currently doing what I want it to (I have it set to pull GPIO5 high when its running, and low when shutdown is complete). Below is what I have in my config.txt

    Code
    #Overlay for GPIO Shutdown
    dtoverlay=gpio-shutdown,gpio_pin=26
    dtoverlay=gpio-poweroff,gpiopin=5,active_low=1

    I will give the keyboard mapping a go, and if that doesn't yield the desired result I will try the script you have linked above. I have an arduino handling this externally, so it will (eventually) shut down after the ignition key being off for 10 minutes - which is long enough for one of my fuel station visits.

    Thanks for the pointers so far. Very helpful. I will post back with my results.

    Cheers

  • A couple of months ago I tested with the gpio-shutdown dtoverlay on LE9 and it worked as expected (power off and on by a button on GPIO3) -no need for any additional python scriptery.

    I haven't used the gpio-poweroff dtoverlay yet, but if it doesn't work please drop me a line and I'll look into it.

    so long,

    Hias

  • Thanks for the help, now working perfectly..

    I put the following in keyboard.xml in the keymap folder...

    XML
    <?xml version="1.0" encoding="UTF-8"?>
    <keymap>
      <global>
        <keyboard>
          <key id="61662">Shutdown</key>
        </keyboard>
    </global>

    Now it shuts down. Also, with the config settings I placed in the earlier post, GPIO5 goes low once shutdown is complete.

    Works perfect. Thanks for all the help!