Hi everyone! Recently, I ran into a very strange problem on my ThinkPad X1 laptop running Ubuntu Linux. Every time I logged into my desktop, my computer went to sleep right away!
It was super annoying, but I finally fixed it. Here is what happened and how I solved it.
What Was the Problem?
I like to use my laptop with the lid closed and connected to a big external monitor. I also enabled a special display setting called Fractional Scaling to make my screen text look bigger and sharper (around 125% to 150%).
However, when I logged into my desktop (X11), Linux refreshed the screen settings. During this split second, the system checked the hardware status and thought: "Hey! The laptop lid is closed! Let's go to sleep!"
So, my computer immediately went to sleep (s2idle) every single time I logged in.
How I Fixed It
The fix is actually very simple! We just need to tell Linux to ignore the closed laptop lid when it is plugged into power or an external screen.
Here are the easy steps:
Step 1: Open the Terminal
Press Ctrl + Alt + T to open your terminal.
Step 2: Edit the System Config File
Type this command to open the configuration file:
sudo nano /etc/systemd/logind.conf
Step 3: Change the Lid Settings
Look for these lines (remove the # at the beginning if there is one) and change their values to ignore:
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore
HandleLidSwitch=ignore: Do not sleep when the lid is closed.HandleLidSwitchExternalPower=ignore: Do not sleep when plugged into power.HandleLidSwitchDocked=ignore: Do not sleep when connected to an external monitor.
Press Ctrl + O then Enter to save, and Ctrl + X to exit.
Step 4: Restart the System Service
Run this command to apply the changes immediately:
sudo systemctl restart systemd-logind
Result
That’s it! Now, my laptop stays awake when I log in, and I can enjoy using my big external screen with custom scaling without any annoying sleep.
If you use your laptop with the lid closed on Linux, I hope this quick tip helps you too!