Taming the power switch? - Printable Version

+- PINE64 (
+-- Forum: Pinebook Pro (
+--- Forum: General Discussion on Pinebook Pro (
+--- Thread: Taming the power switch? (/showthread.php?tid=11773)

Taming the power switch? - ab1jx - 10-10-2020

I'd like to redefine the power switch so it brings up a whiptail confirmation dialog or something like that before it actually shuts off.  Suspend could easily be added to that as another choice.

Is that possible?  I keep hitting it by accident.  I'm using the original Debian Stretch still.  Something like:


TERM=ansi whiptail --title "Power button" --menu "Power Button" 8 20 5 \
"Turn off" "" \
"Suspend" "" \
"Cancel" ""

if [ $choice = 0 ]; then
  echo "Shutting down"
  shutdown now
  if [ $choice = 1 ]; then
    echo "Suspending"
    # write this
    echo "Cancelling"

RE: Taming the power switch? - ab1jx - 11-25-2020

I'm not sure it's actively used, this is in the mrfixit stretch, but see /etc/systemd/logind.conf.  There's even a logind.conf man page.
Fairly simple, looks like:

I haven't really explored it yet but you can change what happens on PowerKey, SuspendKey (which is what?) and all that stuff.  Usually in this format the commented-out entries are the defaults.

RE: Taming the power switch? - wdt - 11-25-2020

To some extent, my experience is that the DE overides login.conf
In KDE, systemsettings5 does this
(power management -> button events checked -> when power button pressed dropdown)

RE: Taming the power switch? - ab1jx - 11-26-2020

Yes, it works.  In /etc/systemd/logind.conf set

I would normally shutdown by typing "halt -p" or "shutdown now" in a terminal.  Or use the logout section of the menu.

I also have HandleLidSwitch=ignore which works mostly.  I think I lose my wifi connection or something like that, I try to set it down without closing the lid.  I usually want to be able to ssh or ftp to it.

I use LXDE for the most part. It has bugs like the clock doesn't update always.
3 days later it seems to be holding fine. I can push the power button and it's ignored. If I close the lid and put it down, when I pick it back up everything's just like I left it. Except when it reboots but that's another matter.

RE: Taming the power switch? - rimaille - 11-30-2020

It's the first thing i did on my pbp (archlinux)
HandlePowerKey=ignore in logind.conf, and then i mapped it in sway.conf to a script that check the state of the screen, if it is on it turn it off, and if it off it turn it on.
This behaviour is persistent even after reboot.