OpenMediaVault installed on laptop - how to turn screen off automatically

A guide to automatically turn off the screen for OpenMediaVault installed on laptop

OpenMediaVault installed on laptop - how to turn screen off automatically
Photo by Maksym Zakharyak / Unsplash

I've just set up OMV on an old laptop, but even if I close the lid the screen stays on. I'm wanting to have it turned off as fully as possible - not just to save the screen but to save whatever processing power it takes if that makes sense.

1. Introduction

In order to save energy and protect the laptop screen, I need to set the screen to the Blank state 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.

2. Make it auto-start

Insert command in executable file

Insert command in executable file. Store it for example in hidden folder of your home directory /home/USER/.boot-scripts/screen-off.sh (Create the folder using mkdir command first):

sudo mkdir /home/USER/.boot-scripts/
sudo nano /home/USER/.boot-scripts/screen-off.sh

Paste this to screen-off.sh file:

#!/bin/bash
setterm --blank 1 --powerdown 2

Save the file by Ctrl+O, Enter, then Ctrl+X

And make script file executable by systemctl

Create file /etc/systemd/system/screen-off.service

sudo nano /etc/systemd/system/screen-off.service

Paste this to screen-off.service file:

[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

Save the file by Ctrl+O, Enter, then Ctrl+X

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

3. Other way to automatically turn screen off on boot

Linux has a boot parameter consoleblank=XX which powers off the tty after XX seconds.
To use this parameter: Edit /etc/default/grub

sudo nano /etc/default/grub

Then add consoleblank=60 to the GRUB_CMDLINE_LINUX_DEFAULT= parameter. For example

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash consoleblank=60"

Then update GRUB and reboot by run:

sudo update-grub
sudo reboot

With this, the display should turn off after one minute (adjust the number if this is too short for you). This will work both on the login prompt, and when someone is logged in.