1. Overview

Laptops running Linux offer users a high level of customization and control over their system settings. Users often seek the ability to disable the automatic suspension of the laptop when the lid is closed. While this feature is useful for conserving power, some users may find it inconvenient.

In this tutorial, we’ll explore the CLI and GUI methods to disable system suspension on lid close in the Linux operating system, allowing users to tailor the system behavior to their preferences.

2. Modifying the logind.conf File – CLI Method

We can disable suspension on lid close via the CLI (Command Line Interface) by modifying the logind.conf file. The systemd service manager, which is a fundamental component of many modern Linux distributions, utilizes logind.conf as its configuration file. This file is located in the /etc/systemd/ folder, which contains settings related to user sessions, power management, and other session-related configurations.

Let’s begin by opening a terminal and modifying the logind.conf file using the nano text editor to disable suspend on lid close:

$ sudo nano /etc/systemd/logind.conf
#ReserveVT=6
#HandleSuspendKey=suspend
#HandleSuspendKeyLongPress=hibernate
#HandleHibernateKey=hibernate
#HandleHibernateKeyLongPress=ignore
#HandleLidSwitch=suspend
#HandleLidSwitchExternalPower=suspend
#HandleLidSwitchDocked=ignore
#PowerKeyIgnoreInhibited=no
...

Now, within the logind.conf file, we’ll need to locate the line containing HandleLidSwitch. This line determines the action to take when we close the laptop lid. Before modifying it, let’s understand what the HandleLidSwitch setting for the laptop lid closing means:

  • HandleLidSwitch: instances when the laptop is operating on battery power
  • HandleLidSwitchExternalPower: scenarios where the laptop is connected to a power outlet
  • HandleLidSwitchDocked: situations when the laptop is linked to a docking station

Let’s change the value of HandleLidSwitch to ignore in the logind.conf file and make sure to uncomment the line. This tells the system to take no action when we close the lid in a situation when the laptop is operating on battery power.

Similarly, we need to save the changes by pressing Ctrl+O, then Enter, and exit the text editor by pressing Ctrl+X.

To apply the changes, let’s restart the systemd-logind service using systemctl:

$ sudo systemctl restart systemd-logind

After restarting systemd-logind, we can verify whether suspend on lid close is disabled when the laptop is operating on battery power.

3. Using gnome-tweaks – GUI Method

The GUI (Graphical User Interface) method for disabling lid close suspension involves using gnome-tweaks specifically designed for the GNOME desktop environment. gnome-tweaks is a powerful tool for customizing the GNOME desktop environment on Linux systems.

If we don’t have gnome-tweaks installed, let’s install it using apt-get:

$ sudo apt-get install gnome-tweaks

Once we install gnome-tweaks, let’s search and start the tweaks application. In the General tab that’s in the left sidebar, we need to turn off the Suspend when laptop lid is closed button:

Turn off Suspend when laptop lid is closed using gnome-tweaks in Ubuntu

Upon turning off the button, it’s not necessary to restart for changes to take effect.

4. Conclusion

In this article, we explored CLI and GUI methods to disable suspension on the lid close of a laptop running Linux.

Upon modifying the logind.conf file through the CLI or using the gnome-tweaks tool for the GNOME desktop environment, we now have the flexibility to disable suspend-on-lid-close in Linux laptops according to our preferences. This customization enhances the user experience by allowing greater control over power management settings in Linux laptops.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments