Already tried all solutions from: How do I disable the sleep button on my keyboard?
gsettings set org.gnome.settings-daemon.plugins.power button-suspend "nothing"
gsettings set org.gnome.settings-daemon.plugins.power button-sleep "nothing"
gsettings set org.gnome.settings-daemon.plugins.power button-hibernate "nothing"
and I have now with dconf-tools:
In my case HP Hewlett Packard WZ972AA ABA Classic Keyboard:
This "Moon" button still working.. Any another ideas?
In addition to the Gnome Power settings you can set the
systemd
settings found in/etc/systemd/logind.conf
:My laptop looks like this:
Notice on my system the only option I've changed is
HandleLidswitch
. For your system I would override these defaults:to this:
systemd
is a little unique in that a line beginning with a hashtag (#
) is not only a comment but also represents the default action taken.Unfortunately I don't have your keyboard to test this configuration.
NOTE: After saving changes either reboot to activate or use:
Not a solution, but a workaround, as it disables suspend.
Follow these two steps:
Add
HandleSuspendKey=ignore
to the[Login]
section of/etc/systemd/logind.conf
.If you have enabled debug level in
logind
logs you get log entries like:in the journal but it still suspends on some other trigger.
Add
/etc/systemd/sleep.conf
with:Now it still reacts on suspend key presses, but fails with:
As said: It's a dirty workaround until someone can find a better solution.
Please try 'xev' to find out if the event (press button) is read by Linux. Maybe the button is direct triggering a function on the mainboard?
On the other hand, if you've got the keycode in
xev
, you should be able to remap the sleep button with something other. See: How do I remap certain keys or devices?It looks like the ability to configure this was removed from recent versions of gnome-settings-daemon in Ubuntu 18 and Ubuntu 20.
A quick and dirty solution is to
killall gsd-media-keys
which will prevent all media keys from being handled by gnome, likely including the lid switch. You'll likely have to have edited/etc/systemd/logind.conf
to make sure logind handles the keys how you like, and restarted the logind service or your system.To re-enable the ability to configure this, some small changes are needed to
plugins/gsd-media-keys-manager.c
inside thegnome-settings-daemon
source. These changes are in a merge request at https://gitlab.gnome.org/GNOME/gnome-settings-daemon/-/issues/537 . Here is how to rebuild gnome-settings-daemon with configuration enabled. You'll have to enable source repositories in your package management system.Under X11, I was able to make the suspend key not suspend, without turning off all the media keys or needing to recompile bits of Gnome.
HandleSuspendKey=ignore
in/etc/systemd/logind.conf
, andsudo systemctl restart systemd-logind
. Note that this kills your user session. I'm not sure if this is strictly necessary.xmodmap -pk | grep Sleep
. I got150
. Then runxmodmap -e 'keycode 150='
to unmap that key, and put that command somewhere, like maybe~/.xinitrc
, where it can run at login.This basic approach is unfortunately reported to be hard to make work under Wayland.