cyberlabs.us | home | subscribe | contact | admin
Monday, July 7th  
| comments  
Ubuntu - Turn off laptop screen - no GUI or X

Ubuntu - Turn off laptop screen - no GUI or X
Informational

/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:

#chmod +x /home/USER/.boot-scripts/screen-off.sh
#chmod +x /etc/systemd/system/screen-off.service

And finally get it working and enabled on boot:

#systemctl start screen-off.service
#systemctl enable screen-off.service

To disable it:

#systemctl disable screen-off.service