How can I tell Ubuntu 20.04 focal to do nothing when I close my laptop lid?

How can I tell Ubuntu 20.04 focal to do nothing when I close my laptop lid?

To check your version:

$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal#

To disable Ubuntu doing anything closing the laptop lid:

Open the /etc/systemd/logind.conf file in a text editor as root, for example,

sudo -H gedit /etc/systemd/logind.conf

If HandleLidSwitch is not set to ignore then change it:

HandleLidSwitch=ignore


# 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.

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=ignore
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#HoldoffTimeoutSec=30s
#IdleAction=ignore
#IdleActionSec=30min
#RuntimeDirectorySize=10%
#RemoveIPC=yes
#InhibitorsMax=8192
#SessionsMax=8192

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.

Restart the systemd daemon (be aware that this will log you off) with this command:


sudo systemctl restart systemd-logind

or, from 15.04 onwards:

sudo service systemd-logind restart




Comments are Closed