I am using Ubuntu 24.04. How can I ensure that the laptop suspends when the lid is closed? I also installed the Tweaks (gnome-tweaks) tool and in Ubuntu 22.04, it used to give a "Suspend when lid is closed" option in the General section, but in Ubuntu 24.04, there is no such option.
3 Answers
In Ubuntu 24.04, laptop lid closure behaviour is primarily managed through systemd, and the default configuration already sets it to suspend. You don't need to modify anything if this is your desired behaviour.
The default configuration is in
/etc/systemd/logind.conf#HandleLidSwitch=suspend #HandleLidSwitchExternalPower=suspend #HandleLidSwitchDocked=ignoreTo override this behaviour, create or edit /etc/systemd/logind.conf.d/99-lid-behavior.conf, using the desired value for the above
<...LidSwitch...>keys:<...LidSwitch...>=lock # only lock screen <...LidSwitch...>=ignore # do nothing (may affect Wi-Fi) <...LidSwitch...>=poweroff # shutdown system <...LidSwitch...>=hibernate # hibernate systemAfter making changes, restart the login service:
sudo systemctl restart systemd-logindRegarding GNOME Tweaks: The lid closure option was indeed removed from GNOME Tweaks in recent versions. The previous dconf key
/org/gnome/settings-daemon/plugins/power/lid-close-ac-actionis no longer valid in 24.04, as this functionality has been fully moved to systemd.
- 78
you can check those settings using Dconf Editor (can be installed by typing dconf on the Ubuntu Store).
After installed, press Super, type dconf and hit Enter to open it. Agree with the warning that will appear the first time, then navigate to:
/org/gnome/settings-daemon/plugins/power/lid-close-ac-action
Once there, you can check or change the value, and also create a Bookmark to go back to that setting easily. Then navigate to:
/org/gnome/settings-daemon/plugins/power/lid-close-battery-action and do the same.
Note that to change the value you have to first turn off the switch Use default value by clicking on it. Then you click the button Custom value and choose the setting that works for you. Test it and post the results here to help the community. Thanks.
- 21
Open the /etc/systemd/logind.conf file in a text editor as root, for example:
vi /etc/systemd/logind.conf
If HandleLidSwitch is not set to ignore then change it:
HandleLidSwitch=ignore
Make sure it's not commented out (it is commented out if it is preceded by the symbol #) or add it if it is missing.
Reboot your machine or Restart the systemd daemon (this will log you off) with this command:
sudo systemctl restart systemd-logind
- 1