By default, Ubuntu automatically suspends your laptop whenever you shut the physical lid. While this power-saving behaviour protects battery life when slipping a portable computer into a rucksack, it creates frustrating interruptions for desk-based workstations. If you dock your laptop to external widescreen monitors, use an external mechanical keyboard and mouse, run local development servers, or download large datasets overnight, closing the lid abruptly halts active processes and drops network connections. Fortunately, Ubuntu provides native configuration switches to keep your system running smoothly with the clamshell closed. Here is how to prevent Ubuntu from suspending when the laptop lid is closed.
Why Keep Ubuntu Awake with the Clamshell Closed?
Configuring your laptop to ignore lid closure offers several workplace advantages:
- Clamshell Workstation Mode: Dock your laptop cleanly on a vertical stand while powering external 4K monitors without keeping the built-in laptop screen lit.
- Uninterrupted Downloads and Backups: Keeps file transfers, system updates, and rsync jobs executing overnight.
- Background Home Server Operations: Allows an older laptop to function as an energy-efficient home media server, print server, or network storage node without occupying desk space.
Method 1: Configure systemd-logind via Terminal (Recommended for All Distros)
The cleanest and most robust method works across all versions of Ubuntu (including Ubuntu 22.04 LTS and Ubuntu 24.04 LTS), irrespective of whether you run GNOME, KDE, XFCE, or a headless setup. It configures the underlying systemd login manager directly:
- Open the Terminal application from your app overview or press
Ctrl + Alt + T. - Open the logind configuration file in the nano text editor with administrative privileges:
sudo nano /etc/systemd/logind.conf - Scroll through the file to locate the line that reads:
#HandleLidSwitch=suspend - Remove the leading
#character to uncomment the directive and change its value toignore:HandleLidSwitch=ignore - If you want your laptop to stay awake when plugged into AC mains power but still suspend on battery, configure both separate triggers instead:
HandleLidSwitchExternalPower=ignore HandleLidSwitchDocked=ignore HandleLidSwitch=suspend - Press
Ctrl + Oand thenEnterto save changes, followed byCtrl + Xto exit nano. - Restart the systemd login daemon to apply the new rules immediately without rebooting your laptop:
sudo systemctl restart systemd-logind
Note: Restarting systemd-logind may briefly lock your graphical session; simply type your user password to unlock your desktop.
Method 2: Use GNOME Tweaks for a Graphical Desktop Solution
If you prefer a visual interface without editing configuration files in terminal, the GNOME Tweaks utility offers an intuitive toggle:
- Open Ubuntu Software (or App Centre), search for GNOME Tweaks, and install it. Alternatively, install via terminal:
sudo apt update && sudo apt install gnome-tweaks -y - Launch Tweaks from your application menu.
- In the left sidebar, click on the General (or Power) tab.
- Locate the option labelled Suspend when laptop lid is closed.
- Toggle the switch to the Off position.
The change takes effect instantly. You can now close your laptop lid while driving external monitors without triggering sleep mode.
Comparison: Systemd logind Configuration Directives
| Setting | Default Value | Recommended Clamshell Setting | Action on Lid Close |
|---|---|---|---|
| HandleLidSwitch | suspend |
ignore |
Leaves CPU, network, and displays active |
| HandleLidSwitchExternalPower | suspend |
ignore |
Stays awake only when charger is attached |
| HandleLidSwitchDocked | ignore |
ignore |
Remains awake when an external display is detected |
Managing Laptop Heat and Power Consumption
When operating a laptop with its screen closed, keep these essential hardware precautions in mind:
- Airflow Considerations: Many slim modern laptops vent exhaust heat through the keyboard deck or hinge. If compiling heavy software or rendering video, ensure the laptop is placed on an elevated stand with adequate ventilation.
- Screen Blanking: Verify in Settings > Power that screen blanking is enabled so your laptop display panel powers off when idle to conserve electricity and prolong display longevity.
With these adjustments applied, your Ubuntu installation functions seamlessly as a compact desktop workstation.