Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Detecting whether a monitor is on or off

15 views
Skip to first unread message

S.K.R. de Jong

unread,
Sep 29, 2021, 8:51:38 AM9/29/21
to
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

unread,
Sep 29, 2021, 9:13:57 AM9/29/21
to
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

unread,
Sep 29, 2021, 2:22:04 PM9/29/21
to
In article <sj1oqj$u8j$1...@dont-email.me>, Rich <ri...@example.invalid> wrote:

>> ... whether or not the monitor is turned on?

> 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.

It is possible it will lie to you too :(

> 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

unread,
Sep 30, 2021, 12:14:30 AM9/30/21
to
Mike <m...@signal11.invalid> wrote:
> In article <sj1oqj$u8j$1...@dont-email.me>, Rich <ri...@example.invalid> wrote:
>
>>> ... whether or not the monitor is turned on?
>
>> 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.
>
> 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

unread,
Sep 30, 2021, 1:55:47 AM9/30/21
to
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

unread,
Sep 30, 2021, 2:55:13 AM9/30/21
to
On 30.09.2021 at 05:55, Henrik Carlqvist scribbled:

> 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 =

Mike

unread,
Sep 30, 2021, 8:52:07 AM9/30/21
to
In article <sj3dj4$8r1$1...@dont-email.me>, Rich <ri...@example.invalid> wrote:

>>>> ... 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.

S.K.R. de Jong

unread,
Sep 30, 2021, 11:16:15 AM9/30/21
to
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.

S.K.R. de Jong

unread,
Sep 30, 2021, 11:22:07 AM9/30/21
to
On Thu, 30 Sep 2021 13:32:49 +0100, Mike wrote:

> In article <sj3dj4$8r1$1...@dont-email.me>, Rich <ri...@example.invalid>
> wrote:
>
>>>>> ... 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

unread,
Sep 30, 2021, 3:18:59 PM9/30/21
to
S.K.R. de Jong <SK...@nowhere.net> wrote:
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.

Rich

unread,
Sep 30, 2021, 3:22:20 PM9/30/21
to
S.K.R. de Jong <SK...@nowhere.net> wrote:
> On Wed, 29 Sep 2021 13:13:55 +0000, Rich wrote:
>
>> S.K.R. de Jong <SK...@nowhere.net> wrote:
>>> 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.
>
> 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,

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

> 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).

> 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.

Henrik Carlqvist

unread,
Oct 1, 2021, 1:27:23 AM10/1/21
to
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

unread,
Oct 1, 2021, 2:46:41 AM10/1/21
to
On 01.10.2021 at 05:27, Henrik Carlqvist scribbled:
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.)

Mike Small

unread,
Oct 1, 2021, 11:44:36 AM10/1/21
to
Rich <ri...@example.invalid> writes:

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

unread,
Oct 1, 2021, 1:06:42 PM10/1/21
to
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

Ralph Spitzner

unread,
Oct 3, 2021, 11:01:19 AM10/3/21
to
S.K.R. de Jong wrote on 9/29/21 2:51 PM:
try " xrandr --query".
should list available displays as disconnected, if off...

-rasp
0 new messages