Taming the power switch?
#1
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:

Code:
#!/bin/bash

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

choice=$?
if [ $choice = 0 ]; then
  echo "Shutting down"
  shutdown now
else
  if [ $choice = 1 ]; then
    echo "Suspending"
    # write this
  else
    echo "Cancelling"
  fi
fi
  Reply
#2
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:
Code:
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192
#UserTasksMax=33%

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.
  Reply
#3
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)
  Reply
#4
Yes, it works.  In /etc/systemd/logind.conf set
HandlePowerKey=ignore
(reboot)

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.
  Reply
#5
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.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Replacement Power Cord recommendation? nathanielwheeler 3 363 01-23-2021, 06:43 PM
Last Post: KC9UDX
  power light blinking during charge when pbpro is off Idaho 0 381 01-04-2021, 10:53 AM
Last Post: Idaho
  Power consumption and suspend to ram robt 33 12,457 11-30-2020, 04:32 PM
Last Post: wdt
Exclamation Seemingly lost power permanently now /cry jimsurvak 2 731 11-16-2020, 06:22 PM
Last Post: jimsurvak
  Taming the Caps Lock key ab1jx 2 742 10-10-2020, 09:30 AM
Last Post: ab1jx
Photo Faulty power circuit hackerfantastic 1 802 08-24-2020, 01:48 PM
Last Post: Arwen
  We need more power, Scotty! mtnygard 4 1,701 07-23-2020, 11:21 AM
Last Post: mamboman777
  My PBP does not power on at all prokofiev 9 2,497 07-12-2020, 03:27 AM
Last Post: prokofiev
Exclamation [SOLVED] PBP will no longer power on s3rvant 10 3,468 07-04-2020, 01:57 PM
Last Post: prokofiev
  Battery draining with external power while under load? RndmNmbr 17 5,385 06-24-2020, 08:33 PM
Last Post: Syonyk

Forum Jump:


Users browsing this thread: 1 Guest(s)