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:

enter image description here

In my case HP Hewlett Packard WZ972AA ABA Classic Keyboard:

enter image description here

This "Moon" button still working.. Any another ideas?

5 Answers 5


In addition to the Gnome Power settings you can set the systemd settings found in /etc/systemd/logind.conf:

My laptop looks like this:

$ cat /etc/systemd/logind.conf

#  This file is part of systemd.
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
# See logind.conf(5) for details.


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:

sudo systemctl restart systemd-logind.service
  • 2
    this method doesn't works
    – Crantisz
    Commented Mar 26, 2019 at 6:44
  • 1
    @Crantisz I added sudo systemctl restart systemd-logind.service to answer. Do you have the same keyboard as shown in question? What make and model of computer do you have? Commented Mar 26, 2019 at 10:28
  • This worked for me on 18.04
    – Rolch2015
    Commented Dec 6, 2020 at 19:28
  • Doesn't work for a Lenovo P52 (sleep button in top right corner) under Ubuntu 20.04. The systemctl restart ... gave me a black screen so I had to reboot anyway.
    – lolesque
    Commented Apr 28, 2022 at 13:18

Not a solution, but a workaround, as it disables suspend.
Follow these two steps:

  1. 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:

    ... systemd-logind[518]: Refusing operation, as it is turned off. 

    in the journal but it still suspends on some other trigger.

  2. Add /etc/systemd/sleep.conf with:


    Now it still reacts on suspend key presses, but fails with:

    ...systemd-logind[518]: Failed to process message type=method_call  
    sender=:1.54 destination=:1.1 path=/org/freedesktop/login1  
    interface=org.freedesktop.login1.Manager member=Suspend cookie=26  
    reply_cookie=0 signature=b error-name=n/a error-message=n/a:  
    Sleep verb not supported in journal

As said: It's a dirty workaround until someone can find a better solution.

  • @zx485 Could you please review my edits and also review the editing help to improve the readability of your own edits in the future... ;-)
    – Fabby
    Commented Apr 6, 2019 at 21:07
  • 1
    @Fabby: I reviewed your edit and admit that my edit was not the best. It was incomplete. I also read the editing help page - again.
    – zx485
    Commented Apr 6, 2019 at 21:28
  • @zx485 0:-) We live and we learn... ;-)
    – Fabby
    Commented Apr 6, 2019 at 21:48

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?

  • Here the log: KeymapNotify event, serial 112, synthetic NO, window 0x0, keys: 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    – Crantisz
    Commented Mar 26, 2019 at 6:44

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 the gnome-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.

$ mkdir ~/local-debs
$ cd ~/local-debs

# install build dependencies
$ sudo apt-get build-dep gnome-settings-daemon

# extract distribution package source
$ sudo apt-get source gnome-settings-daemon

# download the changes
$ wget https://siasky.net/CABb_suQRoRKqFo9zJ9YvGIqlLcpila1OFjUtI-f7uS5xQ/suspend-button-settings

# apply the changes.  `true` as an editor skips editing by making it always successful.
$ cd gnome-settings-daemon-*/
$ patch -p1 < ../suspend-button-settings
$ EDITOR=true dpkg-source --commit . suspend-button-settings ../suspend-button-settings

# build the package, skipping tests and signing
$ DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc

# install the package
$ sudo dpkg -i ../*.deb

# reboot the system, relogin, or terminate and relaunch the `gsd-media-keys` process ...
# ... [do preferred choice] ...

# finally, disable the suspend button
$ gsettings set org.gnome.settings-daemon.plugins.power suspend-button-action "nothing"

# you can also set it to "interactive" instead of "nothing" to display a power popup
  • I don't think this feature has made it into the gnome-settings-daemon that ships with 22.04 either.
    – interfect
    Commented Jun 27, 2022 at 21:23
  • In the merge request link, somebody has suggested an existing configuration key, which may make the patch unnecessary; I'm not sure, as I haven't tried it.
    – fuzzyTew
    Commented Jun 29, 2022 at 20:13
  • It looks like they suggest gsettings set org.gnome.settings-daemon.plugins.media-keys suspend-static "[]". I just ran that, and it ran, but I'm not sure if it's sufficient since I already applied my workaround.
    – interfect
    Commented Jul 1, 2022 at 0:38

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.

  1. Set HandleSuspendKey=ignore in /etc/systemd/logind.conf, and sudo systemctl restart systemd-logind. Note that this kills your user session. I'm not sure if this is strictly necessary.
  2. Following these instructions, identify the keycode for the sleep key with xmodmap -pk | grep Sleep. I got 150. Then run xmodmap -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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .