74

I decided to use my Eee PC 1001HA as a home server. I have it connected through Wi-Fi to the router, running Ubuntu Server 12.04. Everything works fine except this annoying problem:

when I close the lid, the ssh server stops working and, I guess, wlan0 too.

Tried the BIOS and nothing, no option about the lid. My wlan0 is a RaLink RT3090.

Tried ls -lrt /var/log between lid derivatives, but I can't understand those satanic logs. I can share them if needed.

pm-powersave.log seems to be updated between lid movements. So I guess I've to disable this "powersave" service. Can I do this? I don't mind if the server runs all day.

Remember that there is no UI, this is a netbook with a lid and its connected to the ac adapter.

edit: This is just a workaround but I am able to click the power-button and close the lid quickly. This way the server boots normally and connects to the wireless network automatically. (found here)

3

10 Answers 10

127

To disable entering the sleep mode I had to edit the /etc/systemd/logind.conf file and modify the line:

#HandleLidSwitch=suspend

to

HandleLidSwitch=ignore

Additionally, ensure that the file also has this line:

LidSwitchIgnoreInhibited=no

Then restart the OS via:

sudo service systemd-logind restart
13
  • 3
    sudo sh -c 'echo "HandleLidSwitch=ignore" >> /etc/systemd/logind.conf' && reboot Dec 22, 2015 at 5:38
  • 3
    Worked for me on 16.06 (Lenovo Thinkpad P50)
    – Simon B
    Aug 9, 2016 at 7:23
  • 1
    meybe systemctl restart systemd-logind ?? on Ubuntu 16.4 LTS
    – Pas_
    Nov 14, 2016 at 18:39
  • 8
    HandleLidSwitch=lock If you want the extra security
    – myol
    Dec 24, 2016 at 23:00
  • 3
    What if I want the display to turn off? Feb 2, 2018 at 2:32
13

Turn off laptop screen when closed

This works for me on a new install of Ubuntu Server LTS 18.04.1.

The answer from @user386160 worked great to prevent my laptop from going to sleep. But I found out that my monitor was staying on even when the lid was closed (a.k.a. generating unnecessary heat).

Here's the additional steps I took to turn off the laptop monitor when the screen was closed:

sudo apt-get install acpi-support vbetool
sudo echo "event=button/lid.*" > /etc/acpi/events/lid-button
sudo echo "action=/etc/acpi/lid.sh" >> /etc/acpi/events/lid-button
sudo touch /etc/acpi/lid.sh
sudo chmod +x /etc/acpi/lid.sh
sudo nano /etc/acpi/lid.sh

Then set the contents of the lid.sh file to the following:

#!/bin/bash

grep -q close /proc/acpi/button/lid/*/state

if [ $? = 0 ]; then
    sleep 0.2 && vbetool dpms off
fi

grep -q open /proc/acpi/button/lid/*/state

if [ $? = 0 ]; then
    vbetool dpms on
fi
2
  • Should be top answer, who wants the screen on with the lid closed?
    – MrR
    Dec 18, 2021 at 19:46
  • Didn't work for me on Lenovo ideapad 100, Ubuntu 22.04
    – Shubhzgang
    Jul 20 at 18:15
11

just to confirm, 14.04 LTS Server user here on a Dell X100e.

sudo apt-get install acpi-support
sudo vi /etc/default/acpi-support # and then set SUSPEND_METHODS="none"
sudo /etc/init.d/acpid restart

Instantly able to close lid, no issues.

Just posting to confirm the previous posters' solution as the only fix needed. No need (currently) to do anything else in addition to this.

2
  • 3
    This did not work for me on server 14.04 LTS. After applying these changes, when I close the lid, the disk drive runs for a second and then wifi goes out.
    – lonstar
    Dec 13, 2014 at 16:04
  • 1
    This did nothing for me on my Asus G73JW, Ubuntu server 15 , HandleLidSwitch did
    – VeenarM
    Dec 24, 2015 at 12:10
6

Everything stops working because...the laptop goes to sleep! (suspend mode).

To stop, just disable the ACPI lid-button event.

Edit /etc/acpi/event/lidbtn and comment out the bottom two lines:

  # /etc/acpi/events/lidbtn
  # Called when the user closes or opens the lid
  event=button[ /]lid  # comment this out with a # at the beginning
  action=/etc/acpi/lid.sh # same here 

Reboot, and that should be it.

1
  • 8
    Hi izx, I dont have that file. My "/etc/acpi/" has one file "powerbtn". And the "/etc/acpi/events" has another file with same name: "powerbtn"
    – WhyWhat
    May 25, 2012 at 5:54
4

I am using 14.04 LTS with ASUS EEE.

The solution by Stephan above didn't work for me. However, this answer worked.

1
3

I think setting the SUSPEND_METHODS="none" option in /etc/default/acpi-support, does the same thing

3

Editing the /etc/systemd/logind.conf helped, but not with only adding

HandleLidSwitch=ignore

I also had to add the lines:

HandleLidSwitchDocked=ignore

and

LidSwitchIgnoreInhibited=no
1

This worked for me - my Ubuntu Server install didn't have /etc/acpi/event/lidbtn either, but I installed the acpi-support package and then it showed up.

The package installs a whole bunch of other X11 related packages but doesn't enable graphical mode, don't worry.

Once I commented the last two lines as above then my laptop stayed running with the lid closed.

1

Another approach,

for me on Ubuntu Server 20.10, changing logind.conf did not help (although I've also done that, haven't tested this solution without those changes in that file), and the

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

-approach caused systemd to consume 100% of my CPU, but from this manpage https://manpages.ubuntu.com/manpages/cosmic/man5/systemd-sleep.conf.5.html I managed to get it to work (no reboot or anything) by disabling sleep in it's entirety; In /etc/systemd/sleep.conf add the following lines

AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

Although that might not be an option if you want to be able to suspend it etc. in some other situation, but at least it worked for me.

0

Approach that worked for me running Ubuntu Server 22.04 on a MacBook Pro 7,1; edit the login.conf file and utilize setterm cli command. This also helped make sure my screen and logo backlight turned off.

Edit file: /etc/systemd/logind.conf Adjust these two parameters:

HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore

Also, in the terminal, type: setterm --blank 1 --powerdown 2

1
  • got this error setterm: terminal xterm-256color does not support --blank
    – Alex Deft
    Sep 11 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.