How to use Raspberry 5 Power Button with DietPi

With Raspberry 4, I used the SLC pin together with myGPIOd to create an On/Off switch, but Raspberry 5 ships with a power button and you can add an external Button to the J2 jumper.

Raspberry 5 J2 Jumper

This is described in the Raspberry documentation.

You can enable the button easily in DietPi:

  • Set HandlePowerKey=poweroff in /etc/systemd/logind.conf
  • Make sure that ACPI, DBus is installed and activate systemd-logind:

    apt install acpi dbus
    systemctl unmask systemd-logind
    systemctl start systemd-logind