6

I have a laptop that's turned on 24/7, it runs debian with no windowing system (just tty). I've looked through various posts that recommend setterm or vbetool and i've tried making a systemd startup script but this doesn't work. These methods also don't work over ssh.

How will i turn off the screen on my laptop at startup? or ssh?

(Closing the lid and modifying /etc/systemd/logind.conf doesn't work because if i then reboot it over ssh, it won't start back up again because the bios will put it into sleep mode, i can't change this behavior in the bios)

EDIT: I'm sorry if this is a critical detail but i totally forgot to say that i have added nomodeset to the kernel options in /etc/default/grub.

1
  • 1
    What Debian version? 12 aka Bookworm?
    – marcelm
    Nov 29, 2023 at 12:57

3 Answers 3

7

EDIT: I'm sorry if this is a critical detail but i totally forgot to say that i have added nomodeset to the kernel options in /etc/default/grub.

Then you cannot power off the screen, because with nomodeset you have disabled most of your GPU driver, together with all of the output controls that it normally provides.


Original answer:

setterm should work; however, the way it works is by performing special operations on its input terminal, so if you need to use it from SSH or from a service, you must specifically redirect its input and output to one of the "console" terminals. In addition to that, sometimes it uses Linux-specific ioctl calls but sometimes it uses terminal-level "ANSI codes", so you also need to override TERM with one that would be appropriate for the Linux console (instead of whatever you get via SSH).

# TERM=linux setterm --blank force </dev/tty1 >/dev/tty1
[Service]
Type=oneshot
Environment="TERM=linux"
ExecStart=setterm --blank force
StandardInput=tty
TTYPath=/dev/tty1
# (StandardInput=file:/dev/tty1 may actually work better.)

If this doesn't turn off the screen, try adding --powersave powerdown.

You can also completely disable the video output at kernel level; boot with the kernel option video=LVDS-1:D to disable the output named 'LVDS-1'. (Check /sys/class/drm to find the output names.)

vbetool is not likely to work anymore, as it functioned by directly calling into the "Video BIOS" and that's not how modern systems do things. (Even then it kind of bypassed the OS and sometimes would end up confusing it.)

1
  • The /sys/class/drm directory only contains one file called version which says drm 1.1.0 20060810. Trying the service, it hangs when i try systemctl start xxx.service
    – user9503
    Nov 29, 2023 at 8:39
4

Kernel boot parameter: consoleblank

Linux has a boot parameter consoleblank=XX which powers off the tty after XX seconds.

To use this parameter:

  • Edit /etc/default/grub
  • Find the line with GRUB_CMDLINE_LINUX="foo=bar"
  • Add the parameter: GRUB_CMDLINE_LINUX="consoleblank=60 foo=bar"
  • Run update-grub
  • Reboot

With this, the display should turn off after one minute (adjust the number if this is too short for you). This will work both on the login prompt, and when someone is logged in.

It won't affect Wayland. Not sure about classic Xorg.


setterm may be useful as well, but I have found that to be a bit brittle. It stopped working for me sometimes, without a clear reason why. It's also harder to set properly (needs to be run at boot, but needs to be run on an actual tty).

2
  • Added consoleblank=10 and it didn't do anything.
    – user9503
    Nov 29, 2023 at 22:51
  • Are you still using nomodeset as per your update? Then it won't work indeed.
    – marcelm
    Nov 30, 2023 at 19:06
-1

Definitely something of a hack, but if you just want to get it done, echoing into the ACPI interface file via ssh/startup script is an option. Simply echo 0 to turn the screen off, and echo the value of /sys/class/backlight/acpi_video0/max_brightness to turn it back on. Depending on your graphics card, acpi_video0 might be named differently.

# turn_screen_off.sh

echo 0 >> /sys/class/backlight/acpi_video0/brightness

Do note that the script must be run as root to work unless you employ some udev trickery.

8
  • 1
    There are no files in the /sys/class/backlight/ directory.
    – user9503
    Nov 29, 2023 at 8:28
  • @user9503 hard to say what might cause that. Skimming through similar problems suggests that it might be a missing video driver or that kernel parameters might help. That last link also suggests incompatibilities with nomodeset on NVIDIA laptops. Most backlight controls (that I know of) deal with the ACPI at some point, so whatever is causing this might have broken other methods of turning off the laptop screen. Nov 29, 2023 at 9:51
  • The laptop only has an iGPU, I tried acpi_backlight=video/vendor/native and they all didn't create any files in /sys/class/backlight/
    – user9503
    Nov 29, 2023 at 12:29
  • 1
    @user9503: Yeah that's kind of important. Don't do that. With nomodeset you're literally disabling all the output control mechanisms that the GPU driver provides. Nov 30, 2023 at 4:46
  • 1
    @user9503 I sincerely doubt that. nomodeset is, for these things, a sledgehammer solution. There's probably a better way to fix your boot problem, e.g. by specifying a certain resolution or bit depth. If you want to explore that, it's best to ask a new question. Either way, with nomodeset, you'll likely not find a good way to turn off the display.
    – marcelm
    Nov 30, 2023 at 19:12

You must log in to answer this question.

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