TWIMC, if the solution proposed by @marek-vach does not fully work (the screen is blanked but not powered off, e.g. on a Mac running Linux), here's the possible fix.
Tested on MacBook Pro 15" 2013 running Fedora 41 Minimal headless.
Remove his solution if you set it up.
Add kernel parameter consoleblank=60.
This will lead to screen blanking (but not powering off) 60 seconds after boot and 60 seconds after any key press.
You could test it by simply pressing 'e' on grub screen during boot and adding this to the cmd line after something like "rhgb quiet".
To persist, update /etc/default/grub and add it to the end of GRUB_CMDLINE_LINUX before the finishing quote. Something like
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-... rhgb quiet consoleblank=60"
Then run something like to regenerate your grub config.
grub2-mkconfig -o /boot/grub2/grub.cfg
- Create the following script and set it executable.
> cat /usr/bin/screen-powersaving
#!/bin/sh -ex
DELAY="$1"
POWERSAVE_MODE="$2"
/usr/bin/setterm --powersave="${POWERSAVE_MODE:-powerdown}" --term=linux </dev/tty1 >/dev/tty1
{
/bin/sleep "$DELAY"
/usr/bin/setterm --blank=poke --term=linux </dev/tty1 >/dev/tty1
} &
> chown root:root /usr/bin/screen-powersaving
> chmod +x /usr/bin/screen-powersaving
> ls -Al /usr/bin/screen-powersaving
-rwxr-xr-x. 1 root root 231 Nov 10 10:54 /usr/bin/screen-powersaving
This script sets powersaving mode to power off, unless you pass a second parameter overriding it, and then pokes (wakes up) the screen after N delay, which you MUST pass as the first parameter.
- Create the following systemd service.
> cat /etc/systemd/system/screen-powersaving.service
[Unit]
Description=Set screen powersaving mode and poke it once after delay.
After=ssh.service
[Service]
Type=oneshot
ExecStart=/usr/bin/screen-powersaving 2m
KillMode=process
[Install]
WantedBy=multi-user.target
> ls -Al /etc/systemd/system/screen-powersaving.service
-rw-r--r--. 1 root root 215 Nov 10 11:03 /etc/systemd/system/screen-powersaving.service
- Enable this service.
> systemctl daemon-reload
> systemctl enable --now screen-powersaving.service
Created symlink '/etc/systemd/system/multi-user.target.wants/screen-powersaving.service' → '/etc/systemd/system/screen-powersaving.service'.
After reboot, the behaviour would be as follows:
- screen would blank roughly 60 seconds (consoleblank=60) after boot
- it would then wake up roughly 60 seconds later (screen-powersaving 2m)
- it would then blank AND power off roughly 60 seconds later (consoleblank=60)
- and every time you press a key and wake it up, it would blank AND power off roughly 60 seconds later (consoleblank=60)
Feel free to adjust consoleblank=60 and screen-powersaving 2m delays to your liking.
Bear in mind that consoleblank=60 seems to start counting once grub passes control to kernel boot process, and it seems it remembers the powersave mode set at that time. screen-powersaving 2m starts counting moments before you see login prompt on the screen.
You should set the delays so that screen-powersaving 2m ends AFTER first consoleblank=60 ends. Otherwise, the screen will stay blanked until you wake it up manually once. After that it will blank AND power off every consoleblank=60 seconds. And both should finish after you see the login prompt.
As a rule of thumb, at minimum set consoleblank=X to 1.5 your bootup time, and screen-powersaving Xs to the same value.