Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4484

Raspberry Pi OS • Console Blanking - systemd unit file

$
0
0
The Linux kernel disabled console blanking by default in 2017. https://git.kernel.org/pub/scm/linux/ke ... 0a7b0a99ed This is very unhelpful for users wanting to boot to console (such as when the Pi is accessed remotely over ssh, but still has a monitor connected). This means of the various inputs to your monitor, the Pi console output will keep your monitor on preventing power-down/power-save mode from working on the monitor.

This was always the downside consequence of the decision to disable console blanking in the kernel. Thankfully, you can create a simple system-unit file and drop it in /etc/systemd/system to restore the default 5 min blank, 6 min DPMS powerdown. The following named console-blanking.service works fine:

Code:

## systemd service file to restore default blanking and powerdown for#  virtual consoles after a given timeout period (5-min blank, 6-min powerdown)#  this functionality was originally provided by the kernel defaults setting#  /sys/module/kernel/parameters/consoleblank 600 (now 0-disabled). the#  blanking and powerdown were delegated to systemd to implement, but no## service was ever provided by systemd to accomplish this fundamental task.[Unit]Description=Enable virtual console blanking and poweroff[Service]Type=oneshotEnvironment=TERM=linuxStandardOutput=ttyTTYPath=/dev/consoleExecStart=/usr/bin/setterm -blank 5 -powerdown 6[Install]WantedBy=multi-user.target
As a user service file it will be enabled by default on next boot. You can simply start the service sudo systemctl start console-blanking to enable for the current boot without the need to restart the Pi.

Let me know if you have comments or improvements.

Statistics: Posted by drankinatty — Thu Jan 25, 2024 4:04 am — Replies 0 — Views 62



Viewing all articles
Browse latest Browse all 4484

Trending Articles