The Computer Oracle

Change Behavior of Linux Power Button

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Quirky Dreamscape Looping

--

Chapters
00:00 Change Behavior Of Linux Power Button
00:35 Accepted Answer Score 21
01:13 Answer 2 Score 16
01:35 Answer 3 Score 60
02:08 Answer 4 Score 1
02:33 Thank you

--

Full question
https://superuser.com/questions/699905/c...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #linuxmint #powermanagement #cat

#avk47



ANSWER 1

Score 60


terdon's answer is correct in most cases, but for distributions that have adopted systemd-logind it handles power events instead of acpid. On those distributions, add or edit this setting /etc/systemd/logind.conf to disable the power button:

HandlePowerKey=ignore

To pick up the new setting, restart logind with

sudo systemctl restart systemd-logind

On some older distributions logind can't be restarted while a desktop session is active, in which case you'll need to reboot in order to pick up the new setting.




ACCEPTED ANSWER

Score 21


Well, one thing you could do is simply disable the power button altogether. Personally, I only use it to turn on my machine, and never use it once the machine is on. If this is an OK solution for you, edit /etc/acpi/events/powerbtn-acpi-support:

sudo nano /etc/acpi/events/powerbtn-acpi-support

That file should look something like this:

event=button[ /]power
action=/etc/acpi/powerbtn-acpi-support.sh

To make the power button do nothing, change it to:

event=button[ /]power
action=

Then restart the acpi daemon with

sudo service acpid restart

Your power button should now be ignored.




ANSWER 3

Score 16


Duct-tape a cardboard guard over the button. Take three pieces of corrugated cardboard, and cut a hole in each large enough for your finger to reach through to the button. Glue them together, with the hole aligned, then duct tape the assembly around the button. All hail our feline overlords!




ANSWER 4

Score 1


First you could edit your keymap file to change the behavior of the power button to assign it to an other key

Edit the file : /usr/share/X11/xkb/symbols/inet (edit POWR key)

Then you will need to disable the power button efficiently a good method is with xinput

run xinput --list power buttons have their own entry... pick the device number then run

xinput disable devnumber something like xinput disable 8