Disable hibernation/sleep button

Hello!
Ubuntu Version:
24.04

Problem Description:
I need to disable the hibernation or suspend button. I have an HP Probook 650 G5 model.

  • Thank you!

From the terminal CLI

systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

to re-enable

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

here is a article from tecmint describing your objective

Usually I’ll disable the suspend/hibernate on my Dell’s by editing the /etc/systemd/logind.conf file. after running

 sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target 

which I’ll look for a line containing #HandleLidSwitch=suspend which I will uncomment by removing the hashtag
then selecting one of the following lines to insert based on my desired outcome from closing the lid

HandleLidSwitch=suspend
will suspend computer when lid is closed

HandleLidSwitch=hibernate
will hibernate computer when lid is closed

HandleLidSwitch=poweroff
will shutdown computer when lid is closed

then my prefered setting

HandleLidSwitch=ignore
which will do nothing when the lid is closed, and continue to run without suspension or hibernation being invoked

will this method work on a HP ? it might IDK as I don’t have any HP’s to test it on

UNLESS you are trying to remap the actual keys on the keyboard that places the HP into hibernate.