pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

20241104-cut_the_power.md (2387B)


      1 If you have young children you will be familiar with how their little fingers always like to press buttons.
      2 
      3 Especially the power button on your laptop.  When you're in the middle of something.
      4 
      5 Well no more!
      6 
      7 It is possible to disable to power off function of a power button (this was tested on a Thinkpad running Linux with systemd).
      8 
      9 Edit the file _/etc/systemd/logind.conf_
     10 ```
     11 #  This file is part of systemd.
     12 #
     13 #  systemd is free software; you can redistribute it and/or modify it under the
     14 #  terms of the GNU Lesser General Public License as published by the Free
     15 #  Software Foundation; either version 2.1 of the License, or (at your option)
     16 #  any later version.
     17 #
     18 # Entries in this file show the compile time defaults. Local configuration
     19 # should be created by either modifying this file (or a copy of it placed in
     20 # /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
     21 # the /etc/systemd/logind.conf.d/ directory. The latter is generally
     22 # recommended. Defaults can be restored by simply deleting the main
     23 # configuration file and all drop-ins located in /etc/.
     24 #
     25 # Use 'systemd-analyze cat-config systemd/logind.conf' to display the full config.
     26 #
     27 # See logind.conf(5) for details.
     28 
     29 [Login]
     30 #NAutoVTs=6
     31 #ReserveVT=6
     32 #KillUserProcesses=no
     33 #KillOnlyUsers=
     34 #KillExcludeUsers=root
     35 #InhibitDelayMaxSec=5
     36 #UserStopDelaySec=10
     37 #SleepOperation=suspend-then-hibernate suspend
     38 #HandlePowerKey=off
     39 #HandlePowerKeyLongPress=ignore
     40 #HandleRebootKey=reboot
     41 #HandleRebootKeyLongPress=poweroff
     42 #HandleSuspendKey=suspend
     43 #HandleSuspendKeyLongPress=hibernate
     44 #HandleHibernateKey=hibernate
     45 #HandleHibernateKeyLongPress=ignore
     46 #HandleLidSwitch=suspend
     47 #HandleLidSwitchExternalPower=suspend
     48 #HandleLidSwitchDocked=ignore
     49 #PowerKeyIgnoreInhibited=no
     50 #SuspendKeyIgnoreInhibited=no
     51 #HibernateKeyIgnoreInhibited=no
     52 #LidSwitchIgnoreInhibited=yes
     53 #RebootKeyIgnoreInhibited=no
     54 #HoldoffTimeoutSec=30s
     55 #IdleAction=ignore
     56 #IdleActionSec=30min
     57 #RuntimeDirectorySize=10%
     58 #RuntimeDirectoryInodesMax=
     59 #RemoveIPC=yes
     60 #InhibitorsMax=8192
     61 #SessionsMax=8192
     62 #StopIdleSessionSec=infinity
     63 ```
     64 
     65 Uncomment and modify the value of `#HandlePowerKey=off` to `ignore`, then reboot.
     66 
     67 This solution was posted by jeremija on [AskUbuntu][askubuntu].
     68 
     69 Now my little ones can push the power button to their hearts content without shutting down my system.
     70 
     71 [askubuntu]: https://askubuntu.com/a/362931