16

Hi i'm trying to set up an old laptop as a 'server' for testing purposes.

As such, I don't want the screen on all day, however i do want the cpu running 24x7.

Can the 'lid close' switch be configured somehow to simply turn off the screen but otherwise the laptop is running as normal?

FYI: I'm running coreos, but i'm willing to switch to another docker container OS if it makes life easier.

2

4 Answers 4

11

I'm not sure how you missed it in the docs, because when I looked it was plainly there.

Place this in logind.conf:

HandleLidSwitch=ignore
7
  • 7
    Ah yes but I'd like the screen to still turn off
    – Chris
    Dec 6, 2015 at 12:00
  • 2
    Did it not turn off? Dec 6, 2015 at 12:08
  • You're right! Thanks so much. Sorry for wasting your time.
    – Chris
    Dec 6, 2015 at 12:19
  • 10
    I've done this, but my screen is on while the lid is closed :(
    – Hubro
    Sep 18, 2017 at 21:07
  • 4
    I've done this, too, but my screen is still on while the lid is closed. Jun 10, 2018 at 0:46
4

Several people have commented that they can stop their laptop from suspending when closed, but the screen stays on. Maybe this is due to differences in firmware? There is an alternative feature that might work.

At one point, the Linux kernel text console had a default setting that blanked itself after a period of inactivity. An equivalent to the screensaver in your favourite graphical environment :).

Some people like to set the blank time using the kernel boot option consoleblank=, which takes a value in seconds. However, the console blanking feature does not ask the display to enter any power-saving mode.

Remember the original function of a screensaver, was to avoid burning-in a permanent ghost image on your CRT display. It does not necessarily save power. When full power saving was introduced, it was used after a longer delay. Bringing the display back up and running could take a few seconds, which would be much more annoying to the user.


http://man7.org/linux/man-pages/man1/setterm.1.html

Apparently it is possible to enable console blanking at runtime, using setterm --consoleblank [1-60]. And then setterm has another option --powerdown [1-60], to eventually enable "powerdown mode" after a timeout.

If I'm reading it correctly, there's a sequence. First the console blank timeout applies. Then after one powerdown timeout, it applies "vsync suspend mode". Finally after a second powerdown timeout, it applies "powerdown mode". These timeouts are all specified in minutes, not seconds.

So I think you can use a command like this:

 /bin/setterm -term linux -blank 10 -powerdown 5 </dev/tty1 >/dev/tty1

I'm not sure whether CoreOS lets you add arbitrary commands to the boot process (as in rc.local on other distributions, for example). I imagine you can always use a privileged container :).


setterm --blank says that blanking uses APM if available. Narrator voice: APM is not available on modern hardware. I don't know if blanking will use any modern power saving scheme.

"powerdown" mentions "VESA" display power saving. "VESA" power saving is still a thing. I don't know if "powerdown" is necessary or even sufficient to work for modern stuff.

setterm does not say what the default "powerdown" settings are. It looks like "powerdown" is not enabled by default.

3

According to the documentation at this url, the HandleLidSwitch can be set to lock which locks your session and normally causes the screen to turn off either immediately of a few seconds later. This works well on my Ubuntu-Gnome 17.10. The only downside is you'll have to input your password again when you reopen the lid.

Just add the following line in your /etc/systemd/logind.conf

HandleLidSwitch=lock

Note that there is also a HandleLidSwitchExternalPower if you want different behavior when plugged.

The full set of possible values for HandleLidSwitch and HandleLidSwitchExternalPower is:ignore, poweroff, reboot, halt, kexec, suspend, hibernate, hybrid-sleep, suspend-then-hibernate, and lock

2
  • Welcome to posting on U&L! A Core OS server doesn't run X (graphics), unless you're very determined to do so. So for the original asker there won't be any graphical session to lock. Since you bumped this, I've suggested an alternative answer :). If you're writing your answer because it solved a related but different problem which you had, it might be worth writing your problem as a question. You are allowed and indeed encouraged to specify your own answer when you write a question :). I'm not saying this post is a big problem, but if the thread did get too cluttered it might be off-topic
    – sourcejedi
    Jul 7, 2018 at 18:10
  • 1
    (If you wanted to post a separate question, you could always include a link, saying "similar to this other question, but I have Ubuntu Gnome installed and using =ignore leaves my screen on, is there some other approach that lets me trigger the normal screen lock?" or whatever).
    – sourcejedi
    Jul 7, 2018 at 18:15
1

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
  • 1
    Is the last one, setterm permanent or do I need to do it for every boot?
    – mix3d
    Sep 5, 2022 at 2:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .