Discussion:
Detecting whether a monitor is on or off
(too old to reply)
S.K.R. de Jong
2021-09-29 12:51:35 UTC
Permalink
I frequently connect over VNC to a system running Slackware 14.2
where an X windows session is running on a monitor connected over
DisplayPort to that system.

Without being physically there, would it be possible to detect,
from the 14.2 command line, whether or not the monitor is turned on? I
have done an online search for solutions and came across a number of
things that seem to work for some people under Red Hat or Ubuntu - but
have yet to find anything that works under Slackware.
Rich
2021-09-29 13:13:55 UTC
Permalink
Post by S.K.R. de Jong
I frequently connect over VNC to a system running Slackware 14.2
where an X windows session is running on a monitor connected over
DisplayPort to that system.
Without being physically there, would it be possible to detect,
from the 14.2 command line, whether or not the monitor is turned on? I
have done an online search for solutions and came across a number of
things that seem to work for some people under Red Hat or Ubuntu - but
have yet to find anything that works under Slackware.
Provided you have the DISPLAY variable set to point at the remote X
server, then it is possible that "xset q" will tell you what you want.

One of the things that it returns is:

DPMS (Energy Star):
Standby: 600 Suspend: 600 Off: 600
DPMS is Enabled
Monitor is On

Note the "Monitor is On" line.
Mike
2021-09-29 18:19:17 UTC
Permalink
Post by Rich
... whether or not the monitor is turned on?
it is possible that "xset q" will tell you what you want.
Standby: 600 Suspend: 600 Off: 600
DPMS is Enabled
Monitor is On
Note the "Monitor is On" line.
It is possible it will lie to you too :(
Post by Rich
sleep 3 ; xset q
(Turns off monitor, counts to 10)

Returns :-

Keyboard Control:
...

DPMS (Energy Star):
Standby: 1200 Suspend: 1800 Off: 0
DPMS is Enabled
Monitor is On

No, it wasn't :)

Maybe this is only querying whether the computer thinks the
monitor should be active/blanked/part sleeped/deep sleeped,
rather than interrogating the monitor to find if the power
is on.
--
--------------------------------------+------------------------------------
Mike Brown: mjb[-at-]signal11.org.uk | http://www.signal11.org.uk
Rich
2021-09-30 04:14:28 UTC
Permalink
Post by Mike
Post by Rich
... whether or not the monitor is turned on?
it is possible that "xset q" will tell you what you want.
Standby: 600 Suspend: 600 Off: 600
DPMS is Enabled
Monitor is On
Note the "Monitor is On" line.
It is possible it will lie to you too :(
...
Maybe this is only querying whether the computer thinks the
monitor should be active/blanked/part sleeped/deep sleeped,
rather than interrogating the monitor to find if the power
is on.
What it tells you is whether X has used the DPMS signalling to instruct
the monitor to turn itself off.

If you are looking for it being physically turned on/off, then this
method will not help detect that fact.
Henrik Carlqvist
2021-09-30 05:55:45 UTC
Permalink
Post by Rich
Post by Mike
Post by Rich
... whether or not the monitor is turned on?
it is possible that "xset q" will tell you what you want.
Standby: 600 Suspend: 600 Off: 600 DPMS is Enabled Monitor
is On
Note the "Monitor is On" line.
It is possible it will lie to you too :(
...
Maybe this is only querying whether the computer thinks the monitor
should be active/blanked/part sleeped/deep sleeped,
rather than interrogating the monitor to find if the power is on.
What it tells you is whether X has used the DPMS signalling to instruct
the monitor to turn itself off.
If you are looking for it being physically turned on/off, then this
method will not help detect that fact.
Many years ago, before Xorg was able to automagically select the right
resolution for your monitor (maybe this was on the XFree86 days) you had
to edit your Xorg.conf or xfree86.conf to add modelines which matched
your monitor. Somehow I was able to automate this during install calling
some program which queried the monitors capabilities using dpms and then
added the needed modelines to xorg.conf. Once xorg.conf fixed this
automagically I no longer needed this in my custom installation scripts
and I have now forgotten what the name of the program was.

A similar program is dmidecode, but that was not the tool used to query
monitor capabilities.

My guess is that the program querying the monitor for resolutions will
only work if the monitor is on.

Maybe the command was xcmddc, but then possibly it only did work with
VGA monitors.

regards Henrik
Aragorn
2021-09-30 06:55:10 UTC
Permalink
Post by Henrik Carlqvist
Many years ago, before Xorg was able to automagically select the
right resolution for your monitor (maybe this was on the XFree86
days) you had to edit your Xorg.conf or xfree86.conf to add modelines
which matched your monitor. [...]
https://www.commandlinux.com/man-page/man1/xvidtune.1.html
--
With respect,
= Aragorn =
Henrik Carlqvist
2021-10-01 05:27:21 UTC
Permalink
Post by Aragorn
Post by Henrik Carlqvist
Many years ago, before Xorg was able to automagically select the right
resolution for your monitor (maybe this was on the XFree86 days) you
had to edit your Xorg.conf or xfree86.conf to add modelines which
matched your monitor. [...]
https://www.commandlinux.com/man-page/man1/xvidtune.1.html
I don't think xvidtune was the program I was looking for, but I remember
xvidtune as well and it is related. If I remember right xvidtune was a
graphical program which allowed you to fine tune the timings resulting in
new modelines. In those days of analog video you needed to adjust the
horizontal position of the image on the screen. This could be done by
knobs on the screen or by adjusting the modeline.

The program that I was looking for was run on the command line without X
started. This program could give the data needed to write the modelines
needed in xorg.conf or xfree86.conf and once that file was complete it
was possible to start X with a resolution best suited for your monitor.

regards Henrik
Aragorn
2021-10-01 06:46:39 UTC
Permalink
Post by Henrik Carlqvist
Post by Aragorn
Post by Henrik Carlqvist
Many years ago, before Xorg was able to automagically select the
right resolution for your monitor (maybe this was on the XFree86
days) you had to edit your Xorg.conf or xfree86.conf to add
modelines which matched your monitor. [...]
https://www.commandlinux.com/man-page/man1/xvidtune.1.html
I don't think xvidtune was the program I was looking for, but I
remember xvidtune as well and it is related. If I remember right
xvidtune was a graphical program which allowed you to fine tune the
timings resulting in new modelines. In those days of analog video you
needed to adjust the horizontal position of the image on the screen.
This could be done by knobs on the screen or by adjusting the
modeline.
The program that I was looking for was run on the command line
without X started. This program could give the data needed to write
the modelines needed in xorg.conf or xfree86.conf and once that file
was complete it was possible to start X with a resolution best suited
for your monitor.
I remember that utility too, but I thought it was called xvidtune.

It was either way back in the days of XFree86, and X.Org is somewhat
different in terms of its executables, plus that even XFree86 has
changed a lot since then. (We're talking about 20 years ago here.)
--
With respect,
= Aragorn =
Mike
2021-09-30 12:32:49 UTC
Permalink
Post by Rich
Post by Mike
... whether or not the monitor is turned on?
Maybe this is only querying whether the computer thinks the
monitor should be active/blanked/part sleeped/deep sleeped,
rather than interrogating the monitor to find if the power
is on.
What it tells you is whether X has used the DPMS signalling to instruct
the monitor to turn itself off.
If you are looking for it being physically turned on/off, then this
method will not help detect that fact.
So that very much depends on whether the OP *actually* wants to know :-

"whether or not the monitor is turned on?" meaning at the power switch, or

"whether or not the computer last told the monitor to ..." which is a
different question.
--
--------------------------------------+------------------------------------
Mike Brown: mjb[-at-]signal11.org.uk | http://www.signal11.org.uk
S.K.R. de Jong
2021-09-30 15:22:05 UTC
Permalink
Post by Mike
Post by Rich
Post by Mike
... whether or not the monitor is turned on?
Maybe this is only querying whether the computer thinks the monitor
should be active/blanked/part sleeped/deep sleeped,
rather than interrogating the monitor to find if the power is on.
What it tells you is whether X has used the DPMS signalling to instruct
the monitor to turn itself off.
If you are looking for it being physically turned on/off, then this
method will not help detect that fact.
So that very much depends on whether the OP *actually* wants to know :-
"whether or not the monitor is turned on?" meaning at the power switch, or
"whether or not the computer last told the monitor to ..." which is a
different question.
The first one: I would like to know whether the monitor is
physically turned on - i.e. plugged into the electric outlet and with the
power button in the on position.

Can this be done from Slackware?
Rich
2021-09-30 19:18:56 UTC
Permalink
Post by S.K.R. de Jong
Post by Mike
Post by Rich
Post by Mike
... whether or not the monitor is turned on?
Maybe this is only querying whether the computer thinks the
monitor should be active/blanked/part sleeped/deep sleeped, rather
than interrogating the monitor to find if the power is on.
What it tells you is whether X has used the DPMS signalling to
instruct the monitor to turn itself off.
If you are looking for it being physically turned on/off, then this
method will not help detect that fact.
So that very much depends on whether the OP *actually* wants to know :-
"whether or not the monitor is turned on?" meaning at the power switch, or
"whether or not the computer last told the monitor to ..." which is
a different question.
The first one: I would like to know whether the monitor is
physically turned on - i.e. plugged into the electric outlet and
with the power button in the on position.
Can this be done from Slackware?
I feel that this request is not possible from any OS without you first
building the sensors and computer interface necessary to read those
sensors from the attached PC.
Mike Small
2021-10-01 15:44:34 UTC
Permalink
Post by Rich
Post by S.K.R. de Jong
The first one: I would like to know whether the monitor is
physically turned on - i.e. plugged into the electric outlet and
with the power button in the on position.
Can this be done from Slackware?
I feel that this request is not possible from any OS without you first
building the sensors and computer interface necessary to read those
sensors from the attached PC.
Would he need to write a kernel driver? Or if he could take the output
of a light sensor to a parallel port line or joystick pin is there
already something available on the kernel side to make it a simple
userland program to read off the bit?
--
Mike Sm.
Rich
2021-10-01 17:06:40 UTC
Permalink
Post by Rich
Post by S.K.R. de Jong
The first one: I would like to know whether the monitor is
physically turned on - i.e. plugged into the electric outlet and
with the power button in the on position.
Can this be done from Slackware?
I feel that this request is not possible from any OS without you
first building the sensors and computer interface necessary to read
those sensors from the attached PC.
Would he need to write a kernel driver? Or if he could take the
output of a light sensor to a parallel port line or joystick pin is
there already something available on the kernel side to make it a
simple userland program to read off the bit?
Only if he did not use an existing I/O interface that already has a
kernel driver written.

Existing I/O interfaces that could be used and that have a kernel
driver:

1) parallel port (if the system has a parallel port)
2) serial port (if the system has a serial port)
3) joystick port (if the system has a joystick port)
4) USB
5) microphone input
6) ... there could be many more, less common, ones
S.K.R. de Jong
2021-09-30 15:16:11 UTC
Permalink
Post by Rich
Post by S.K.R. de Jong
I frequently connect over VNC to a system running Slackware 14.2
where an X windows session is running on a monitor connected over
DisplayPort to that system.
Without being physically there, would it be possible to detect,
from the 14.2 command line, whether or not the monitor is turned on? I
have done an online search for solutions and came across a number of
things that seem to work for some people under Red Hat or Ubuntu - but
have yet to find anything that works under Slackware.
Provided you have the DISPLAY variable set to point at the remote X
server, then it is possible that "xset q" will tell you what you want.
Standby: 600 Suspend: 600 Off: 600 DPMS is Enabled Monitor is
On
Note the "Monitor is On" line.
I tried that first, but this is what I get:

DPMS (Energy Star):
Standby: 7200 Suspend: 7200 Off: 14400
DPMS is Disabled

I don't know why DPMS is disabled, and before enabling it I would
like to have the certainty that doing such a thing is not going to mess
up with my existing X session.

This aside, many people report that the output from xset q is not
reliable in this respect: it may tell you that the monitor is on when it
really is off, or vice-versa.
Rich
2021-09-30 19:22:18 UTC
Permalink
Post by S.K.R. de Jong
Post by Rich
Post by S.K.R. de Jong
I frequently connect over VNC to a system running Slackware 14.2
where an X windows session is running on a monitor connected over
DisplayPort to that system.
Without being physically there, would it be possible to detect,
from the 14.2 command line, whether or not the monitor is turned on? I
have done an online search for solutions and came across a number of
things that seem to work for some people under Red Hat or Ubuntu - but
have yet to find anything that works under Slackware.
Provided you have the DISPLAY variable set to point at the remote X
server, then it is possible that "xset q" will tell you what you want.
Standby: 600 Suspend: 600 Off: 600 DPMS is Enabled Monitor is
On
Note the "Monitor is On" line.
Standby: 7200 Suspend: 7200 Off: 14400
DPMS is Disabled
I don't know why DPMS is disabled,
Likely you never enabled it, or specifically disabled it at some point.
DPMS stands for Display Power Management Ssignaling and is a VESA
standard that allows the attached computer to signal the monitor to
enter a low power state.

https://en.wikipedia.org/wiki/VESA_Display_Power_Management_Signaling
Post by S.K.R. de Jong
and before enabling it I would like to have the certainty that doing
such a thing is not going to mess up with my existing X session.
Turning it on should do nothing to your existing session (other than
allow the computer to automatically power down your monitor when you
are not using the computer).
Post by S.K.R. de Jong
This aside, many people report that the output from xset q is
not reliable in this respect: it may tell you that the monitor is on
when it really is off, or vice-versa.
The output from xset tells you whether the computer is signaling the
monitor to turn off or not. Whether the monitor is truly off depends
upon whether the monitor responds to DPMS power down signals and powers
down in response.
Ralph Spitzner
2021-10-03 15:01:15 UTC
Permalink
Post by S.K.R. de Jong
I frequently connect over VNC to a system running Slackware 14.2
where an X windows session is running on a monitor connected over
DisplayPort to that system.
Without being physically there, would it be possible to detect,
from the 14.2 command line, whether or not the monitor is turned on? I
have done an online search for solutions and came across a number of
things that seem to work for some people under Red Hat or Ubuntu - but
have yet to find anything that works under Slackware.
try " xrandr --query".
should list available displays as disconnected, if off...

-rasp

Loading...