Software & AppsOperating SystemLinux

How To fix Dell XPS13 9370 not suspending on lid close in Ubuntu 18.04

Ubuntu 18

In this article, we will be discussing how to fix an issue that some users of the Dell XPS13 9370 laptop have experienced when running Ubuntu 18.04 – the laptop not suspending when the lid is closed.

Quick Answer

To fix the issue of Dell XPS13 9370 not suspending on lid close in Ubuntu 18.04, you can try editing the logind.conf file to enable lid switch suspension, testing the suspend functionality of your system, or creating a custom systemd service to handle the lid close event. Restart your system after making any changes for them to take effect.

Understanding the Issue

The Dell XPS13 9370 is a popular laptop model among Ubuntu users due to its robust hardware and compatibility with the Linux operating system. However, some users have reported that their laptop does not suspend when they close the lid, a feature that is supposed to save power and extend battery life.

Prerequisites

Before we start, ensure that you have administrative access to your Ubuntu system. You’ll need to use terminal commands, and some of them require superuser (root) privileges.

Solution 1: Editing the Systemd Configuration

The first solution involves editing the logind.conf file, which is part of the systemd system and service manager.

  1. Open a terminal window.
  2. Enter the following command to open the logind.conf file in a text editor:
sudo nano /etc/systemd/logind.conf
  1. In the opened file, find the lines that read #HandleLidSwitch=suspend and #HandleLidSwitchDocked=suspend.
  2. Remove the “#” at the beginning of these lines to uncomment them. The lines should now read HandleLidSwitch=suspend and HandleLidSwitchDocked=suspend.
  3. Save the file and exit the text editor. In nano, you can do this by pressing Ctrl+X, then Y to confirm saving changes, and finally Enter to confirm the file name.
  4. Restart your system for the changes to take effect.

This change tells systemd to suspend the system whenever the lid is closed, whether the laptop is docked or not.

Solution 2: Testing Suspend Functionality

If the above solution does not work, you should check if your system can suspend properly.

  1. Open a terminal window.
  2. Enter the following command to manually suspend your system:
sudo systemctl suspend

If your system does not suspend properly (i.e., the fans stay on, the power light stays on, etc.), it indicates a deeper issue with the suspend functionality on your system.

Solution 3: Creating a Custom Systemd Service

If the above solutions do not work, you can create a custom systemd service to handle the lid close event. This solution is a bit more involved and requires creating a new script and service file.

  1. Create a new script file in /usr/local/bin/:
sudo nano /usr/local/bin/lid-close.sh
  1. In the new file, enter the following script:
#!/bin/bash
grep -q closed /proc/acpi/button/lid/*/state
if [ $? = 0 ]
then
 sudo systemctl suspend
fi

This script checks if the lid is closed and, if it is, suspends the system.

  1. Save the file and make it executable:
sudo chmod +x /usr/local/bin/lid-close.sh
  1. Create a new systemd service file:
sudo nano /etc/systemd/system/lid-close.service
  1. In the new file, enter the following:
[Unit]
Description=Lid close actions
Before=sleep.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/lid-close.sh

[Install]
WantedBy=multi-user.target

This service runs the lid-close.sh script when the system is about to enter sleep mode.

  1. Enable the new service:
sudo systemctl enable lid-close.service
  1. Restart your system for the changes to take effect.

This solution should fix the issue of your Dell XPS13 9370 not suspending when the lid is closed on Ubuntu 18.04. If you’re still experiencing issues, it may be worth reaching out to the Ubuntu community or Dell support for further assistance.

How do I open a terminal window in Ubuntu 18.04?

To open a terminal window in Ubuntu 18.04, you can use the keyboard shortcut Ctrl+Alt+T. Alternatively, you can search for "Terminal" in the applications menu and click on the Terminal icon to open it.

How do I edit a file using the nano text editor in Ubuntu?

To edit a file using the nano text editor in Ubuntu, you can use the command nano <file_path>. For example, to edit the logind.conf file mentioned in the article, you would use the command sudo nano /etc/systemd/logind.conf. Once the file is open in nano, you can make your changes, save the file by pressing Ctrl+X, then Y to confirm saving changes, and finally Enter to confirm the file name.

How do I restart my system in Ubuntu 18.04?

To restart your system in Ubuntu 18.04, you can use the command sudo reboot. This will initiate a system restart. Alternatively, you can click on the power icon in the top-right corner of the screen and choose "Restart" from the drop-down menu.

How do I make a script file executable in Ubuntu?

To make a script file executable in Ubuntu, you can use the command chmod +x <file_path>. For example, to make the lid-close.sh script executable, you would use the command sudo chmod +x /usr/local/bin/lid-close.sh. This command grants execute permissions to the script file.

How do I enable a systemd service in Ubuntu?

To enable a systemd service in Ubuntu, you can use the command sudo systemctl enable <service_name>. For example, to enable the lid-close.service created in the article, you would use the command sudo systemctl enable lid-close.service. This command ensures that the service starts automatically at boot.

Leave a Comment

Your email address will not be published. Required fields are marked *