I’ve recently installed Ubuntu server on an old laptop to use it as a homeserver. Since I want to keep the power consumption as low as possible, I tried to disable the display after a certain period of inactivity. This was harder to establish than I have thought. Anyways, I have found a solution.
Initially, the laptop used about 9 watts, after disabling the screen it went down to almost 2 watts.
Common Problems
If commands are executed via SSH, they are within another environment (esp. TERM) as if one would do it directly via keyboard. A typical error message is:
setterm: terminal xterm-256color does not support --blank
System Attributes
- Laptop: Acer Aspire Switch Alpha 12
- Ubuntu: 22.04.2 LTS
- uname -a: Linux p-11 5.15.0-71-generic #78-Ubuntu SMP Tue Apr 18 09:00:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Solution
Create new service
sudo vi /etc/systemd/system/enable-console-blanking.service
Put the following content into this file:
[Unit]
Description=Enable virtual console blanking
[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=/usr/bin/setterm -blank 1
[Install]
WantedBy=multi-user.target
And enable after reboot
sudo chmod 664 /etc/systemd/system/enable-console-blanking.service
sudo systemctl enable enable-console-blanking.service
Reboot, and after one minute screen should go blank and power consumption.
Credits for this solution goes to Tobias Holm on askubuntu.com.