NimbUx
Posts: 279
Joined: Fri Jan 03, 2020 10:33 am

know a command-line for turning off the screen ? [SOLVED]

Thu Jul 30, 2020 6:11 pm

Do we have a command - in Terminal under Raspi-OS desktop - for turning off the display, immediately,
and preferably so it does not turn on by itself on detecting mouse movement (unlike the regular screen saver) ?
Last edited by NimbUx on Tue Aug 04, 2020 6:23 pm, edited 1 time in total.

bjtheone
Posts: 1284
Joined: Mon May 20, 2019 11:28 pm
Location: The Frozen North (AKA Canada)

Re: know a command-line for turning off the screen ?

Fri Jul 31, 2020 2:56 pm

The following will blank the screen:

Code: Select all

sleep 1 ; xset dpms force off
DPMS is Display Power Management Signaling, a standard to reduce power consumption in monitors. xset is of course an X utility. If you need to accomplish this without X involved, use setterm:

setterm -powerdown 1

The full list of options to manipulate your screen:

xset -dpms # Disable DPMS
xset +dpms # Enable DPMS
xset s off # Disable screen blanking
xset s 150 # Blank the screen after 150 seconds
xset dpms 300 600 900 # Set standby, suspend, & off times (in seconds)
xset dpms force standby # Immediately go into standby mode
xset dpms force suspend # Immediately go into suspend mode
xset dpms force off # Immediately turn off the monitor
xset -q # Query current settings

setterm -blank 10 # Blank the screen in 10 minutes
setterm -powersave on # Put the monitor into VESA power saving mode
setterm -powerdown 20 # Set the VESA powerdown to 20 minutes

GlowInTheDark
Posts: 1712
Joined: Sat Nov 09, 2019 12:14 pm

Re: know a command-line for turning off the screen ?

Fri Jul 31, 2020 3:00 pm

Which of course begs the obvious question:

How to get it back?

Note that this may be related to my recent adventure with "dm-tool lock" - where it seems to just brute force turned off the screen(s). Maybe DPMS would have a way to recover from that?
GitD's list of things that are not ready for prime time:
1) IPv6
2) 64 bit OSes
3) USB 3
4) Bluetooth

Loves Linux; loves to dance.

NimbUx
Posts: 279
Joined: Fri Jan 03, 2020 10:33 am

Re: know a command-line for turning off the screen ?

Fri Jul 31, 2020 4:33 pm

bjtheone wrote:
Fri Jul 31, 2020 2:56 pm
The following will blank the screen:

Code: Select all

sleep 1 ; xset dpms force off
Thanks ! That, in Terminal at the Desktop,
does the job : turn off the screen.

It comes back on at a key press OR by moving the mouse though. I had rather
avoided the latter (because mice often are over-sensitive creatures...)
but it's fine anyway. Oooops ! Rejoiced too soon, the command does blank the
screen but it eventually comes back after an unpredictable time, without touching
the mouse and/or keyboard :=(

Not tried the other variants and propositions.

sparkie777
Posts: 206
Joined: Tue Nov 27, 2012 4:37 am

Re: know a command-line for turning off the screen ?

Sat Aug 01, 2020 10:23 am

turn off console:

Code: Select all

tvservice -o
turn on again:

Code: Select all

tvservice -p
I don't use X11 on RPi. So I can't tell how these commands interact with X11.

NimbUx
Posts: 279
Joined: Fri Jan 03, 2020 10:33 am

SOLVED: a command-line for turning off the screen

Sat Aug 01, 2020 11:14 am

sparkie777 wrote:
Sat Aug 01, 2020 10:23 am

Code: Select all

tvservice -o
... 
tvservice -p
I don't use X11 on RPi. So I can't tell how these commands interact with X11.
I just tried, in the GUI (X) : both commands worked, but after the resume, my Desktop's XY dimensions
were not restored properly, displayed GUI is shrinked, anchored at the left high corner of
the physical screen.

Maybe related to having Linux set to display, normally, to a resolution (1600x900) that
is not my screen's native one (viz 1920x1080)

Now I need another command to expand, inflate the picture again to fill the screen :=).
Have to dig this question more...
{Edit:} solved ! giving the solution out for anybody also scratching his(her) head :
Lookup xrandr ! Example, in my case this command (in Terminal) :

Code: Select all

$ xrandr --output HDMI-1 --mode 1600x900
will restore my regular display mode (which is not the screen's preferred mode)

Return to “Beginners”