How to setup a service that automatically turns off the laptop monitor

If you’re running Umbrel on a laptop (which is the best way, because you get the battery backup in case of power surges), then you can use this guide to setup a service that will automatically shut down the laptop monitor after 5 minutes of idle.
Basically, we create a service file, associate it to a script file, and then enable the service to run on system boot.

cd /etc/systemd/system
sudo nano setterm-blank.service

Add this to the file:

[Unit]
Description=setterm blank script

[Service]
Type=oneshot
ExecStart=/bin/bash /usr/sbin/setterm_blank.sh
RemainAfterExit=true
StandardOutput=journal

[Install]
WantedBy=multi-user.target

Then create the script file:

sudo nano /usr/sbin/setterm_blank.sh

Add this to the script file

#!/bin/bash

setterm -term linux -blank=5 >/dev/console

Then run the following commands to make the script executable and enable the service:

sudo chmod u+x /usr/sbin/setterm_blank.sh

sudo systemctl start setterm-blank

sudo systemctl enable setterm-blank

After 5 minutes of inactivity, the monitor should go blank.