Blank screen after 1 min and turn it off after 2 min. Any keypress will turn it back on. Make it auto-start after reboot.
The magic command what will do all the work:
setterm --blank 1 --powerdown 2
If you get error: setterm: terminal xterm-256color does not support --blank
- You are probably trying this command by SSH. You must run it from local of your machine, or do next stage of this guide.
Make it auto-start
Insert command in executable file. Store it for example in hidden folder of your home directory /home/USER/.boot-scripts/screen-off.sh
#!/bin/bash
setterm --blank 1 --powerdown 2
And make script file executable by systemctl. Create file /etc/systemd/system/screen-off.service
[Unit]
Description=Blank screen after 1 min and turn it off after 2 min. Any keypress will turn it back on.
After=ssh.service
[Service]
Type=oneshot
Environment=TERM=linux
StandardOutput=tty
TTYPath=/dev/console
ExecStart=/home/USER/.boot-scripts/screen-off.sh
[Install]
WantedBy=local.target
Make it executable:
sudo chmod +x /home/USER/.boot-scripts/screen-off.sh
sudo chmod +x /etc/systemd/system/screen-off.service
And finally get it working and enabled on boot:
sudo systemctl start screen-off.service
sudo systemctl enable screen-off.service
To disable it:
sudo systemctl disable screen-off.service