Fix: Ubuntu 25.10 Wakes Up After Lid Close

by Andrew McMorgan 43 views

Hey guys! Having trouble with your Ubuntu 25.10 rig waking up every time you close the lid? You're not alone! It's a pretty common head-scratcher, especially on laptops like the Lenovo ThinkPad P14s. You put your machine into suspend mode using sudo systemctl suspend -f or the GUI, the LED is blinking all cozy-like, and then BAM! You close the lid, and it's back to life. Let's dive into some solutions to keep your laptop snoozing as it should.

Understanding the Issue

Before we jump into fixes, let's break down why this might be happening. Modern operating systems are designed to be smart about power management. They try to balance energy savings with user convenience. Sometimes, however, the default settings don't quite align with what we want. Here are a few potential culprits:

  • ACPI Events: The Advanced Configuration and Power Interface (ACPI) handles power management events, including lid close actions. Incorrectly configured ACPI settings can cause unexpected wake-ups.
  • Wake-on-LAN (WOL): If enabled, WOL allows your computer to be woken up by network activity. This might be useful in some situations, but it can also lead to unwanted wake-ups.
  • USB Devices: Sometimes, a connected USB device might be sending a signal that wakes up the system. This is particularly common with mice or keyboards.
  • BIOS Settings: In rare cases, the BIOS settings might be interfering with the operating system's power management.
  • Driver Issues: Although less common, a buggy driver can sometimes cause unexpected behavior. This could be related to graphics, network, or other hardware components.

Solutions to Keep Ubuntu Asleep

Alright, let's get our hands dirty with some fixes. Here's a step-by-step guide to troubleshoot and resolve this annoying wake-up issue.

1. Check and Modify logind.conf

The first place to start is the logind.conf file, which controls how systemd handles login sessions and power management. This is where you can tell Ubuntu what to do when you close the lid.

  1. Open the Configuration File:

    Open your terminal and use your favorite text editor (like nano or vim) to open the logind.conf file:

    sudo nano /etc/systemd/logind.conf
    
  2. Modify the Settings:

    Look for the following lines. If they're commented out (with a # at the beginning), uncomment them and change their values as follows:

    HandleLidSwitch=suspend
    HandleLidSwitchExternalPower=suspend
    HandleLidSwitchDocked=suspend
    
    • HandleLidSwitch=suspend: This tells Ubuntu to suspend when the lid is closed, regardless of power source.
    • HandleLidSwitchExternalPower=suspend: This tells Ubuntu to suspend when the lid is closed, specifically when the laptop is plugged into external power.
    • HandleLidSwitchDocked=suspend: This tells Ubuntu to suspend when the lid is closed while the laptop is docked.

    If these lines don't exist, you can add them to the file.

  3. Save and Close:

    Save the file (in nano, press Ctrl+X, then Y, then Enter) and close the editor.

  4. Restart the Systemd Login Service:

    Apply the changes by restarting the systemd login service:

    sudo systemctl restart systemd-logind
    

    This command tells systemd to reload the configuration file and apply the new settings. After restarting the service, test if closing the lid now correctly suspends the system.

2. Tweak ACPI Settings

ACPI (Advanced Configuration and Power Interface) handles power management events. Sometimes, the default ACPI behavior can cause issues. Let's see how we can tweak it.

  1. Check ACPI Events:

    Monitor ACPI events to see what happens when you close the lid. Open a terminal and run:

    sudo acpi_listen
    

    Now, close the lid and watch the output. You should see events related to the lid switch. If you see anything unexpected, it might indicate an ACPI problem.

  2. Create a Custom ACPI Script (if needed):

    If the acpi_listen output indicates an issue, you might need to create a custom ACPI script. This is a bit more advanced, but here's the basic idea:

    • Create a new file in /etc/acpi/events/ with a descriptive name (e.g., lid-close).

    • Add the following content to the file:

      event=button/lid.* close
      

action=/etc/acpi/lid.sh ```

*   Create the script `/etc/acpi/lid.sh` with the following content:

    ```bash
    #!/bin/bash

    case "$1" in
        close)
            systemctl suspend
            ;;
        *) # Ignore other events
            ;;
    esac
    ```

*   Make the script executable:

    ```bash
    sudo chmod +x /etc/acpi/lid.sh
    ```

*   Restart the ACPI service:

    ```bash
    sudo systemctl restart acpid
    ```

This script tells ACPI to execute `systemctl suspend` when the lid is closed. Be cautious when creating ACPI scripts, as incorrect configurations can lead to unexpected behavior.

3. Disable Wake-on-LAN (WOL)

WOL allows your computer to be woken up by network activity. If you don't need this feature, disabling it can prevent unwanted wake-ups.

  1. Check Network Interfaces:

    List your network interfaces using:

    ip link show
    

    Identify the interface connected to your network (e.g., eth0 or wlan0).

  2. Disable WOL:

    Disable WOL for the identified interface:

    sudo ethtool -s eth0 wol d
    

    Replace eth0 with your actual interface name. To make this change permanent, you can add a script to /etc/network/if-up.d/:

    sudo nano /etc/network/if-up.d/disable-wol
    

    Add the following content to the file:

    #!/bin/sh
    /sbin/ethtool -s eth0 wol d
    exit 0
    

    Make the script executable:

    sudo chmod +x /etc/network/if-up.d/disable-wol
    

    This script will disable WOL each time the network interface is brought up. Remember to replace eth0 with the correct interface name.

4. Investigate USB Devices

Sometimes, a USB device might be causing the wake-up. Let's investigate and prevent this.

  1. Check Wake-Up Status of USB Devices:

    Use dmesg to check the wake-up status of USB devices:

    dmesg | grep -i usb | grep -i wake
    

    This command filters the dmesg output to show USB-related wake-up events. Look for any devices that might be causing the issue.

  2. Disable USB Wake-Up:

    You can disable USB wake-up using udev rules. Create a new file in /etc/udev/rules.d/ (e.g., 99-usb-wake.rules):

    sudo nano /etc/udev/rules.d/99-usb-wake.rules
    

    Add the following content to the file:

    ACTION==