Sammy_Getty
Sammy_Getty

Reputation: 1

Calling "setterm -blank 10" on a schedule (configuring how long to wait before screens is turned off automatically)

I've GNU/linux Debian 10 (sid) net install with no x11 on a HP Pavilion dv6. I can keep the monitor on alway with:

setterm -blank 0

Then have the monitor shut off after 10 minutes of inactivity with the:

setterm -blank 10.

What I would like to do is have the screen go off at 23:00 every night and come back on every morning at 06:00. I have tried several things in cron and via systemctld.

What I have tried in both is:

setterm -blank 10
setterm -term bash -blank 10
setterm -term fish -blank 10
setterm -term /dev/tty1 -blank 10
setterm -term linux -blank 10
$TERM=linux setterm -blank 10
$TERM=bash setterm -blank 10
$TERM=fish setterm -blank 10
$TERM=/dev/tty1 setterm -blank 10

I have also made a bash script with all of those variations. To no avail. Is it even possible to run setterm in cron or as a systemctld event?

As a secondary note I'm utilizing fish as my shell, also I have to detach from GNU/screen to actually get setterm to work.

Upvotes: 0

Views: 1172

Answers (1)

meuh
meuh

Reputation: 12255

For some options, setterm works by sending a sequence of characters to stdout. Normally, when you are on the console these are therefore read by the console driver and interpreted. Other options do ioctls on stdin similarly.

If you use these commands from cron or a systemd unit, you would need to redirect the output or input to/from the console. For example, from cron, as root, try

setterm -term linux -blank 0 >/dev/console

Or for something using ioctl, set the stdin

setterm -term linux -powersave on </dev/console

If you use the bash shell in cron you can say <>/dev/console to open for in and out.

Upvotes: 1

Related Questions