You are not logged in.

#1 2020-07-28 14:04:51

millus
Member
Registered: 2019-07-21
Posts: 40

How to determine whether HDMI display is turned on or off?

I have a second monitor connected via HDMI (primary is via eDP, the notebook's native screen) and want my script to check whether it's currently turned off or on.

The problem is that xrandr will always say it's "connected" (which is true I guess, as despite turning it off the actual hardware cable will still be connecting the monitor and the notebook of course).
In fact, whether the HDMI-monitor is turned on or off, "$ xrandr" will produce exactly the same output! Even running it with "$ xrandr --verbose" will make no distinction.

For the record I also tried "ddcutil", but "$ ddcutil detect" will always just claim "No displays found", no matter whether the external HDMI is turned on or off. Running it as sudo didn't change this either.

How can I check whether the monitor is actually on or off?

Last edited by millus (2020-07-29 00:53:03)

Offline

#2 2020-07-28 14:28:39

Phrosgone
Member
From: Zurich
Registered: 2016-06-15
Posts: 14

Re: How to determine whether HDMI display is turned on or off?

Try it with xset

Offline

#3 2020-07-28 20:11:32

millus
Member
Registered: 2019-07-21
Posts: 40

Re: How to determine whether HDMI display is turned on or off?

Phrosgone wrote:

Try it with xset

Thanks for your reply. I wanted to *check* the on/off state of the connected HDMI monitor, not *set* anything, though.

Offline

#4 2020-07-28 20:25:52

Phrosgone
Member
From: Zurich
Registered: 2016-06-15
Posts: 14

Re: How to determine whether HDMI display is turned on or off?

Maybe you should read the link:

"The q option gives you information on the current settings."

set -q returns:

DPMS (Energy Star):
  Standby: 1800    Suspend: 2700    Off: 3600
  DPMS is Enabled
  Monitor is On

Offline

#5 2020-07-28 20:47:03

millus
Member
Registered: 2019-07-21
Posts: 40

Re: How to determine whether HDMI display is turned on or off?

Phrosgone wrote:

Maybe you should read the link:

Oh I did read the man page, which clearly states

DESCRIPTION
       This program is used to set various user preference options of the display.

However, thanks for pointing out its inaccuracy. I tried xset and it only says "Monitor is On". In general, it seems that xset cannot distinguish between multiple physical monitors, but just *one* sort of "X output" screen or something, which it simply calls "monitor". I googled xset a bit and a couple of threads I found about xset and dual-monitor setups confirm this theory.
Especially it's not possible to set any specific DISPLAY in conjunction with xset to make this work.

Last edited by millus (2020-07-28 20:48:22)

Offline

#6 2020-07-28 21:16:38

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 23,934
Website

Re: How to determine whether HDMI display is turned on or off?

I doubt DPMS would be relevant regardless.  That essentially tells X to blank (or not send anything to) that screen.  So you can query whether or not the local machine has stopped sending data to the monitor due to DPMS, but this has no relevance on whether the monitor itself is powered on or not.

I'm pretty sure there could not be any Xorg utility that could detect whether an HDMI monitor is physically powered on or not - there is simply no means of communicating this data at the level Xorg works on.  The only way this data could be queried is via HDMI CEC if the monitor suppports it (and your computer does as well).

You could try cec-client from community/libcec to see if the monitor exposes such data (and/or if it supports CEC at all).

EDIT: there's also cec-ctl from extra/v4l-utils

Last edited by Trilby (2020-07-28 21:20:21)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2020-07-28 21:32:15

millus
Member
Registered: 2019-07-21
Posts: 40

Re: How to determine whether HDMI display is turned on or off?

Thanks. Unfortunately there are no /dev/cec* devices so the command refuses to work.
However, somehow the notebook definitely notices when the monitor gets turned on or off, because some windows (eg VLC, but also file manager windows and other stuff) will change their locations accordingly.
So there is SOME kind of notification. I now tried

$ udevadm monitor

and all possible parameters such as property, kernel, udev or subsystem-match drm, and indeed there are a couple of "notifications" happening on power-on/off, but the problem is that they are completely indistinguishable. So the system must still have some other means to know when to move VLC from 2nd monitor to main monitor within the same "big" extended screen (3840x1080 ie 2x 1080p next to each other, defined in arandr).

Offline

#8 2020-07-28 21:35:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 23,934
Website

Re: How to determine whether HDMI display is turned on or off?

Yes, Xorg definitely knows when the root window changes - that's a ConfigureNotify event.  But that would go hand-in-hand with xrandr changes.  Xrandr will report the current "Screen" geometry, generally as it's first line of output "Screen 0: ...".  Is this changing when VLC and other windows get moved around?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2020-07-28 21:58:01

millus
Member
Registered: 2019-07-21
Posts: 40

Re: How to determine whether HDMI display is turned on or off?

Unfortunately not. xrandr will always report

Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384

no matter whether the monitor is actually turned on or off. Ie the screen resolution will be doubled just from plugging in the HDMI cable, even if the hardware (monitor) attached to it is not switched on. xrandr --verbose doesn't make a difference either.

Offline

#10 2020-07-29 05:56:41

seth
Member
Registered: 2012-09-03
Posts: 15,750

Re: How to determine whether HDMI display is turned on or off?

Can you please post the complete xrandr outputs (when the Tv is on and off)?
Also, which "file manager windows and other stuff"™ specifically?

Offline

#11 2020-07-29 08:43:13

millus
Member
Registered: 2019-07-21
Posts: 40

Re: How to determine whether HDMI display is turned on or off?

xrandr when HDMI monitor is on:

Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
eDP1 connected primary 1920x1080+0+0 (0x45) normal (normal left inverted right x axis y axis) 293mm x 165mm
	Identifier: 0x42
	Timestamp:  284122147
	Subpixel:   unknown
	Gamma:      1.0:1.2:1.4
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0 1 2
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	EDID: 
		00ffffffffffff0006af2d2700000000
		10190104951d117802bc05a2554c9a25
		0e505400000001010101010101010101
		010101010101143780b8703824401010
		3e0025a5100000180000000000000000
		00000000000000000000000000fe0041
		554f0a202020202020202020000000fe
		004231333348414e30322e37200a0082
	BACKLIGHT: 93 
		range: (0, 937)
	Backlight: 93 
		range: (0, 937)
	scaling mode: Full aspect 
		supported: Full, Center, Full aspect
	Colorspace: Default 
		supported: Default, RGB_Wide_Gamut_Fixed_Point, RGB_Wide_Gamut_Floating_Point, opRGB, DCI-P3_RGB_D65, BT2020_RGB, BT601_YCC, BT709_YCC, XVYCC_601, XVYCC_709, SYCC_601, opYCC_601, BT2020_CYCC, BT2020_YCC
	max bpc: 12 
		range: (6, 12)
	Broadcast RGB: Automatic 
		supported: Automatic, Full, Limited 16:235
	panel orientation: Normal 
		supported: Normal, Upside Down, Left Side Up, Right Side Up
	link-status: Good 
		supported: Good, Bad
	non-desktop: 0 
		range: (0, 1)
  1920x1080 (0x45) 141.000MHz -HSync -VSync *current +preferred
        h: width  1920 start 1936 end 1952 total 2104 skew    0 clock  67.02KHz
        v: height 1080 start 1083 end 1097 total 1116           clock  60.05Hz
  1920x1080 (0x46) 173.000MHz -HSync +VSync
        h: width  1920 start 2048 end 2248 total 2576 skew    0 clock  67.16KHz
        v: height 1080 start 1083 end 1088 total 1120           clock  59.96Hz
  1920x1080 (0x47) 138.500MHz +HSync -VSync
        h: width  1920 start 1968 end 2000 total 2080 skew    0 clock  66.59KHz
        v: height 1080 start 1083 end 1088 total 1111           clock  59.93Hz
  1680x1050 (0x48) 146.250MHz -HSync +VSync
        h: width  1680 start 1784 end 1960 total 2240 skew    0 clock  65.29KHz
        v: height 1050 start 1053 end 1059 total 1089           clock  59.95Hz
  1680x1050 (0x49) 119.000MHz +HSync -VSync
        h: width  1680 start 1728 end 1760 total 1840 skew    0 clock  64.67KHz
        v: height 1050 start 1053 end 1059 total 1080           clock  59.88Hz
  1400x1050 (0x4a) 122.000MHz +HSync +VSync
        h: width  1400 start 1488 end 1640 total 1880 skew    0 clock  64.89KHz
        v: height 1050 start 1052 end 1064 total 1082           clock  59.98Hz
  1600x900 (0x4b) 118.250MHz -HSync +VSync
        h: width  1600 start 1696 end 1856 total 2112 skew    0 clock  55.99KHz
        v: height  900 start  903 end  908 total  934           clock  59.95Hz
  1600x900 (0x4c) 97.500MHz +HSync -VSync
        h: width  1600 start 1648 end 1680 total 1760 skew    0 clock  55.40KHz
        v: height  900 start  903 end  908 total  926           clock  59.82Hz
  1280x1024 (0x4d) 108.000MHz +HSync +VSync
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
  1400x900 (0x4e) 103.500MHz -HSync +VSync
        h: width  1400 start 1480 end 1624 total 1848 skew    0 clock  56.01KHz
        v: height  900 start  903 end  913 total  934           clock  59.96Hz
  1400x900 (0x4f) 86.500MHz +HSync -VSync
        h: width  1400 start 1448 end 1480 total 1560 skew    0 clock  55.45KHz
        v: height  900 start  903 end  913 total  926           clock  59.88Hz
  1280x960 (0x50) 108.000MHz +HSync +VSync
        h: width  1280 start 1376 end 1488 total 1800 skew    0 clock  60.00KHz
        v: height  960 start  961 end  964 total 1000           clock  60.00Hz
  1368x768 (0x51) 85.250MHz -HSync +VSync
        h: width  1368 start 1440 end 1576 total 1784 skew    0 clock  47.79KHz
        v: height  768 start  771 end  781 total  798           clock  59.88Hz
  1368x768 (0x52) 72.250MHz +HSync -VSync
        h: width  1368 start 1416 end 1448 total 1528 skew    0 clock  47.28KHz
        v: height  768 start  771 end  781 total  790           clock  59.85Hz
  1280x800 (0x53) 83.500MHz -HSync +VSync
        h: width  1280 start 1352 end 1480 total 1680 skew    0 clock  49.70KHz
        v: height  800 start  803 end  809 total  831           clock  59.81Hz
  1280x800 (0x54) 71.000MHz +HSync -VSync
        h: width  1280 start 1328 end 1360 total 1440 skew    0 clock  49.31KHz
        v: height  800 start  803 end  809 total  823           clock  59.91Hz
  1280x720 (0x55) 74.500MHz -HSync +VSync
        h: width  1280 start 1344 end 1472 total 1664 skew    0 clock  44.77KHz
        v: height  720 start  723 end  728 total  748           clock  59.86Hz
  1280x720 (0x56) 63.750MHz +HSync -VSync
        h: width  1280 start 1328 end 1360 total 1440 skew    0 clock  44.27KHz
        v: height  720 start  723 end  728 total  741           clock  59.74Hz
  1024x768 (0x57) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  1024x576 (0x58) 46.500MHz -HSync +VSync
        h: width  1024 start 1064 end 1160 total 1296 skew    0 clock  35.88KHz
        v: height  576 start  579 end  584 total  599           clock  59.90Hz
  1024x576 (0x59) 42.000MHz +HSync -VSync
        h: width  1024 start 1072 end 1104 total 1184 skew    0 clock  35.47KHz
        v: height  576 start  579 end  584 total  593           clock  59.82Hz
  960x540 (0x5a) 40.750MHz -HSync +VSync
        h: width   960 start  992 end 1088 total 1216 skew    0 clock  33.51KHz
        v: height  540 start  543 end  548 total  562           clock  59.63Hz
  960x540 (0x5b) 37.250MHz +HSync -VSync
        h: width   960 start 1008 end 1040 total 1120 skew    0 clock  33.26KHz
        v: height  540 start  543 end  548 total  556           clock  59.82Hz
  800x600 (0x5c) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  800x600 (0x5d) 36.000MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock  35.16KHz
        v: height  600 start  601 end  603 total  625           clock  56.25Hz
  864x486 (0x5e) 32.500MHz -HSync +VSync
        h: width   864 start  888 end  968 total 1072 skew    0 clock  30.32KHz
        v: height  486 start  489 end  494 total  506           clock  59.92Hz
  864x486 (0x5f) 30.500MHz +HSync -VSync
        h: width   864 start  912 end  944 total 1024 skew    0 clock  29.79KHz
        v: height  486 start  489 end  494 total  500           clock  59.57Hz
  640x480 (0x60) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz
  720x405 (0x61) 22.500MHz -HSync +VSync
        h: width   720 start  744 end  808 total  896 skew    0 clock  25.11KHz
        v: height  405 start  408 end  413 total  422           clock  59.51Hz
  720x405 (0x62) 21.750MHz +HSync -VSync
        h: width   720 start  768 end  800 total  880 skew    0 clock  24.72KHz
        v: height  405 start  408 end  413 total  419           clock  58.99Hz
  640x360 (0x63) 18.000MHz -HSync +VSync
        h: width   640 start  664 end  720 total  800 skew    0 clock  22.50KHz
        v: height  360 start  363 end  368 total  376           clock  59.84Hz
  640x360 (0x64) 17.750MHz +HSync -VSync
        h: width   640 start  688 end  720 total  800 skew    0 clock  22.19KHz
        v: height  360 start  363 end  368 total  374           clock  59.32Hz
HDMI1 connected 1920x1080+1920+0 (0x65) normal (normal left inverted right x axis y axis) 1600mm x 900mm
	Identifier: 0x43
	Timestamp:  284122147
	Subpixel:   unknown
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       1
	CRTCs:      0 1 2
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	EDID: 
		00ffffffffffff004ca314a501010101
		1a17010380a05a780ede50a3544c9926
		0f505420000001010101010101010101
		010101010101023a801871382d40582c
		450040846300001e023a80d072382d40
		102c458040846300001e000000fd0018
		550f5c11000a202020202020000000fc
		004550534f4e20504a0a2020202001bb
		02033cf255901f202205140413030212
		1107061615010f0e1e1d230907078301
		000072030c001000b82de02e2e2121c0
		04010000c7e3050000e200fb011d8018
		711c1620582c250040846300009e011d
		80d0721c1620102c258040846300009e
		011d007251d01e206e28550040846300
		001e00000000000000000000000000bd
	HDCP Content Type: HDCP Type0 
		supported: HDCP Type0, HDCP Type1
	Content Protection: Undesired 
		supported: Undesired, Desired, Enabled
	max bpc: 12 
		range: (8, 12)
	content type: No Data 
		supported: No Data, Graphics, Photo, Cinema, Game
	Colorspace: Default 
		supported: Default, SMPTE_170M_YCC, BT709_YCC, XVYCC_601, XVYCC_709, SYCC_601, opYCC_601, opRGB, BT2020_CYCC, BT2020_RGB, BT2020_YCC, DCI-P3_RGB_D65, DCI-P3_RGB_Theater
	aspect ratio: Automatic 
		supported: Automatic, 4:3, 16:9
	Broadcast RGB: Automatic 
		supported: Automatic, Full, Limited 16:235
	audio: auto 
		supported: force-dvi, off, auto, on
	link-status: Good 
		supported: Good, Bad
	non-desktop: 0 
		range: (0, 1)
  1920x1080 (0x65) 148.500MHz +HSync +VSync *current +preferred
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  60.00Hz
  1920x1080 (0x66) 148.500MHz +HSync +VSync
        h: width  1920 start 2448 end 2492 total 2640 skew    0 clock  56.25KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  50.00Hz
  1920x1080 (0x67) 148.352MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.43KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  59.94Hz
  1920x1080i (0x68) 74.250MHz +HSync +VSync Interlace
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.75KHz
        v: height 1080 start 1084 end 1094 total 1125           clock  60.00Hz
  1920x1080i (0x69) 74.250MHz +HSync +VSync Interlace
        h: width  1920 start 2448 end 2492 total 2640 skew    0 clock  28.12KHz
        v: height 1080 start 1084 end 1094 total 1125           clock  50.00Hz
  1920x1080 (0x6a) 74.250MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.75KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  30.00Hz
  1920x1080 (0x6b) 74.250MHz +HSync +VSync
        h: width  1920 start 2558 end 2602 total 2750 skew    0 clock  27.00KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  24.00Hz
  1920x1080i (0x6c) 74.176MHz +HSync +VSync Interlace
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.72KHz
        v: height 1080 start 1084 end 1094 total 1125           clock  59.94Hz
  1920x1080 (0x6d) 74.176MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.72KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  29.97Hz
  1920x1080 (0x6e) 74.176MHz +HSync +VSync
        h: width  1920 start 2558 end 2602 total 2750 skew    0 clock  26.97KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  23.98Hz
  1280x720 (0x6f) 74.250MHz +HSync +VSync
        h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  45.00KHz
        v: height  720 start  725 end  730 total  750           clock  60.00Hz
  1280x720 (0x70) 74.250MHz +HSync +VSync
        h: width  1280 start 1720 end 1760 total 1980 skew    0 clock  37.50KHz
        v: height  720 start  725 end  730 total  750           clock  50.00Hz
  1280x720 (0x71) 74.176MHz +HSync +VSync
        h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  44.96KHz
        v: height  720 start  725 end  730 total  750           clock  59.94Hz
  1440x576 (0x72) 54.000MHz -HSync -VSync
        h: width  1440 start 1464 end 1592 total 1728 skew    0 clock  31.25KHz
        v: height  576 start  581 end  586 total  625           clock  50.00Hz
  1440x480 (0x73) 54.054MHz -HSync -VSync
        h: width  1440 start 1472 end 1596 total 1716 skew    0 clock  31.50KHz
        v: height  480 start  489 end  495 total  525           clock  60.00Hz
  1440x480 (0x74) 54.000MHz -HSync -VSync
        h: width  1440 start 1472 end 1596 total 1716 skew    0 clock  31.47KHz
        v: height  480 start  489 end  495 total  525           clock  59.94Hz
  720x576 (0x75) 27.000MHz -HSync -VSync
        h: width   720 start  732 end  796 total  864 skew    0 clock  31.25KHz
        v: height  576 start  581 end  586 total  625           clock  50.00Hz
  720x576i (0x76) 13.500MHz -HSync -VSync Interlace
        h: width   720 start  732 end  795 total  864 skew    0 clock  15.62KHz
        v: height  576 start  580 end  586 total  625           clock  50.00Hz
  720x480 (0x77) 27.027MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.50KHz
        v: height  480 start  489 end  495 total  525           clock  60.00Hz
  720x480 (0x78) 27.000MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.47KHz
        v: height  480 start  489 end  495 total  525           clock  59.94Hz
  720x480i (0x79) 13.514MHz -HSync -VSync Interlace
        h: width   720 start  739 end  801 total  858 skew    0 clock  15.75KHz
        v: height  480 start  488 end  494 total  525           clock  60.00Hz
  720x480i (0x7a) 13.500MHz -HSync -VSync Interlace
        h: width   720 start  739 end  801 total  858 skew    0 clock  15.73KHz
        v: height  480 start  488 end  494 total  525           clock  59.94Hz
  640x480 (0x7b) 25.200MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.50KHz
        v: height  480 start  490 end  492 total  525           clock  60.00Hz
  640x480 (0x60) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz

xrandr when HDMI monitor is off:

Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 16384 x 16384
eDP1 connected primary 1920x1080+0+0 (0x45) normal (normal left inverted right x axis y axis) 293mm x 165mm
	Identifier: 0x42
	Timestamp:  244653470
	Subpixel:   unknown
	Gamma:      1.0:1.2:1.4
	Brightness: 1.0
	Clones:    
	CRTC:       0
	CRTCs:      0 1 2
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	EDID: 
		00ffffffffffff0006af2d2700000000
		10190104951d117802bc05a2554c9a25
		0e505400000001010101010101010101
		010101010101143780b8703824401010
		3e0025a5100000180000000000000000
		00000000000000000000000000fe0041
		554f0a202020202020202020000000fe
		004231333348414e30322e37200a0082
	BACKLIGHT: 93 
		range: (0, 937)
	Backlight: 93 
		range: (0, 937)
	scaling mode: Full aspect 
		supported: Full, Center, Full aspect
	Colorspace: Default 
		supported: Default, RGB_Wide_Gamut_Fixed_Point, RGB_Wide_Gamut_Floating_Point, opRGB, DCI-P3_RGB_D65, BT2020_RGB, BT601_YCC, BT709_YCC, XVYCC_601, XVYCC_709, SYCC_601, opYCC_601, BT2020_CYCC, BT2020_YCC
	max bpc: 12 
		range: (6, 12)
	Broadcast RGB: Automatic 
		supported: Automatic, Full, Limited 16:235
	panel orientation: Normal 
		supported: Normal, Upside Down, Left Side Up, Right Side Up
	link-status: Good 
		supported: Good, Bad
	non-desktop: 0 
		range: (0, 1)
  1920x1080 (0x45) 141.000MHz -HSync -VSync *current +preferred
        h: width  1920 start 1936 end 1952 total 2104 skew    0 clock  67.02KHz
        v: height 1080 start 1083 end 1097 total 1116           clock  60.05Hz
  1920x1080 (0x46) 173.000MHz -HSync +VSync
        h: width  1920 start 2048 end 2248 total 2576 skew    0 clock  67.16KHz
        v: height 1080 start 1083 end 1088 total 1120           clock  59.96Hz
  1920x1080 (0x47) 138.500MHz +HSync -VSync
        h: width  1920 start 1968 end 2000 total 2080 skew    0 clock  66.59KHz
        v: height 1080 start 1083 end 1088 total 1111           clock  59.93Hz
  1680x1050 (0x48) 146.250MHz -HSync +VSync
        h: width  1680 start 1784 end 1960 total 2240 skew    0 clock  65.29KHz
        v: height 1050 start 1053 end 1059 total 1089           clock  59.95Hz
  1680x1050 (0x49) 119.000MHz +HSync -VSync
        h: width  1680 start 1728 end 1760 total 1840 skew    0 clock  64.67KHz
        v: height 1050 start 1053 end 1059 total 1080           clock  59.88Hz
  1400x1050 (0x4a) 122.000MHz +HSync +VSync
        h: width  1400 start 1488 end 1640 total 1880 skew    0 clock  64.89KHz
        v: height 1050 start 1052 end 1064 total 1082           clock  59.98Hz
  1600x900 (0x4b) 118.250MHz -HSync +VSync
        h: width  1600 start 1696 end 1856 total 2112 skew    0 clock  55.99KHz
        v: height  900 start  903 end  908 total  934           clock  59.95Hz
  1600x900 (0x4c) 97.500MHz +HSync -VSync
        h: width  1600 start 1648 end 1680 total 1760 skew    0 clock  55.40KHz
        v: height  900 start  903 end  908 total  926           clock  59.82Hz
  1280x1024 (0x4d) 108.000MHz +HSync +VSync
        h: width  1280 start 1328 end 1440 total 1688 skew    0 clock  63.98KHz
        v: height 1024 start 1025 end 1028 total 1066           clock  60.02Hz
  1400x900 (0x4e) 103.500MHz -HSync +VSync
        h: width  1400 start 1480 end 1624 total 1848 skew    0 clock  56.01KHz
        v: height  900 start  903 end  913 total  934           clock  59.96Hz
  1400x900 (0x4f) 86.500MHz +HSync -VSync
        h: width  1400 start 1448 end 1480 total 1560 skew    0 clock  55.45KHz
        v: height  900 start  903 end  913 total  926           clock  59.88Hz
  1280x960 (0x50) 108.000MHz +HSync +VSync
        h: width  1280 start 1376 end 1488 total 1800 skew    0 clock  60.00KHz
        v: height  960 start  961 end  964 total 1000           clock  60.00Hz
  1368x768 (0x51) 85.250MHz -HSync +VSync
        h: width  1368 start 1440 end 1576 total 1784 skew    0 clock  47.79KHz
        v: height  768 start  771 end  781 total  798           clock  59.88Hz
  1368x768 (0x52) 72.250MHz +HSync -VSync
        h: width  1368 start 1416 end 1448 total 1528 skew    0 clock  47.28KHz
        v: height  768 start  771 end  781 total  790           clock  59.85Hz
  1280x800 (0x53) 83.500MHz -HSync +VSync
        h: width  1280 start 1352 end 1480 total 1680 skew    0 clock  49.70KHz
        v: height  800 start  803 end  809 total  831           clock  59.81Hz
  1280x800 (0x54) 71.000MHz +HSync -VSync
        h: width  1280 start 1328 end 1360 total 1440 skew    0 clock  49.31KHz
        v: height  800 start  803 end  809 total  823           clock  59.91Hz
  1280x720 (0x55) 74.500MHz -HSync +VSync
        h: width  1280 start 1344 end 1472 total 1664 skew    0 clock  44.77KHz
        v: height  720 start  723 end  728 total  748           clock  59.86Hz
  1280x720 (0x56) 63.750MHz +HSync -VSync
        h: width  1280 start 1328 end 1360 total 1440 skew    0 clock  44.27KHz
        v: height  720 start  723 end  728 total  741           clock  59.74Hz
  1024x768 (0x57) 65.000MHz -HSync -VSync
        h: width  1024 start 1048 end 1184 total 1344 skew    0 clock  48.36KHz
        v: height  768 start  771 end  777 total  806           clock  60.00Hz
  1024x576 (0x58) 46.500MHz -HSync +VSync
        h: width  1024 start 1064 end 1160 total 1296 skew    0 clock  35.88KHz
        v: height  576 start  579 end  584 total  599           clock  59.90Hz
  1024x576 (0x59) 42.000MHz +HSync -VSync
        h: width  1024 start 1072 end 1104 total 1184 skew    0 clock  35.47KHz
        v: height  576 start  579 end  584 total  593           clock  59.82Hz
  960x540 (0x5a) 40.750MHz -HSync +VSync
        h: width   960 start  992 end 1088 total 1216 skew    0 clock  33.51KHz
        v: height  540 start  543 end  548 total  562           clock  59.63Hz
  960x540 (0x5b) 37.250MHz +HSync -VSync
        h: width   960 start 1008 end 1040 total 1120 skew    0 clock  33.26KHz
        v: height  540 start  543 end  548 total  556           clock  59.82Hz
  800x600 (0x5c) 40.000MHz +HSync +VSync
        h: width   800 start  840 end  968 total 1056 skew    0 clock  37.88KHz
        v: height  600 start  601 end  605 total  628           clock  60.32Hz
  800x600 (0x5d) 36.000MHz +HSync +VSync
        h: width   800 start  824 end  896 total 1024 skew    0 clock  35.16KHz
        v: height  600 start  601 end  603 total  625           clock  56.25Hz
  864x486 (0x5e) 32.500MHz -HSync +VSync
        h: width   864 start  888 end  968 total 1072 skew    0 clock  30.32KHz
        v: height  486 start  489 end  494 total  506           clock  59.92Hz
  864x486 (0x5f) 30.500MHz +HSync -VSync
        h: width   864 start  912 end  944 total 1024 skew    0 clock  29.79KHz
        v: height  486 start  489 end  494 total  500           clock  59.57Hz
  640x480 (0x60) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz
  720x405 (0x61) 22.500MHz -HSync +VSync
        h: width   720 start  744 end  808 total  896 skew    0 clock  25.11KHz
        v: height  405 start  408 end  413 total  422           clock  59.51Hz
  720x405 (0x62) 21.750MHz +HSync -VSync
        h: width   720 start  768 end  800 total  880 skew    0 clock  24.72KHz
        v: height  405 start  408 end  413 total  419           clock  58.99Hz
  640x360 (0x63) 18.000MHz -HSync +VSync
        h: width   640 start  664 end  720 total  800 skew    0 clock  22.50KHz
        v: height  360 start  363 end  368 total  376           clock  59.84Hz
  640x360 (0x64) 17.750MHz +HSync -VSync
        h: width   640 start  688 end  720 total  800 skew    0 clock  22.19KHz
        v: height  360 start  363 end  368 total  374           clock  59.32Hz
HDMI1 connected 1920x1080+1920+0 (0x65) normal (normal left inverted right x axis y axis) 1600mm x 900mm
	Identifier: 0x43
	Timestamp:  244653470
	Subpixel:   unknown
	Gamma:      1.0:1.0:1.0
	Brightness: 1.0
	Clones:    
	CRTC:       1
	CRTCs:      0 1 2
	Transform:  1.000000 0.000000 0.000000
	            0.000000 1.000000 0.000000
	            0.000000 0.000000 1.000000
	           filter: 
	EDID: 
		00ffffffffffff004ca314a501010101
		1a17010380a05a780ede50a3544c9926
		0f505420000001010101010101010101
		010101010101023a801871382d40582c
		450040846300001e023a80d072382d40
		102c458040846300001e000000fd0018
		550f5c11000a202020202020000000fc
		004550534f4e20504a0a2020202001bb
		02033cf255901f202205140413030212
		1107061615010f0e1e1d230907078301
		000072030c001000b82de02e2e2121c0
		04010000c7e3050000e200fb011d8018
		711c1620582c250040846300009e011d
		80d0721c1620102c258040846300009e
		011d007251d01e206e28550040846300
		001e00000000000000000000000000bd
	HDCP Content Type: HDCP Type0 
		supported: HDCP Type0, HDCP Type1
	Content Protection: Undesired 
		supported: Undesired, Desired, Enabled
	max bpc: 12 
		range: (8, 12)
	content type: No Data 
		supported: No Data, Graphics, Photo, Cinema, Game
	Colorspace: Default 
		supported: Default, SMPTE_170M_YCC, BT709_YCC, XVYCC_601, XVYCC_709, SYCC_601, opYCC_601, opRGB, BT2020_CYCC, BT2020_RGB, BT2020_YCC, DCI-P3_RGB_D65, DCI-P3_RGB_Theater
	aspect ratio: Automatic 
		supported: Automatic, 4:3, 16:9
	Broadcast RGB: Automatic 
		supported: Automatic, Full, Limited 16:235
	audio: auto 
		supported: force-dvi, off, auto, on
	link-status: Good 
		supported: Good, Bad
	non-desktop: 0 
		range: (0, 1)
  1920x1080 (0x65) 148.500MHz +HSync +VSync *current +preferred
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.50KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  60.00Hz
  1920x1080 (0x66) 148.500MHz +HSync +VSync
        h: width  1920 start 2448 end 2492 total 2640 skew    0 clock  56.25KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  50.00Hz
  1920x1080 (0x67) 148.352MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  67.43KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  59.94Hz
  1920x1080i (0x68) 74.250MHz +HSync +VSync Interlace
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.75KHz
        v: height 1080 start 1084 end 1094 total 1125           clock  60.00Hz
  1920x1080i (0x69) 74.250MHz +HSync +VSync Interlace
        h: width  1920 start 2448 end 2492 total 2640 skew    0 clock  28.12KHz
        v: height 1080 start 1084 end 1094 total 1125           clock  50.00Hz
  1920x1080 (0x6a) 74.250MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.75KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  30.00Hz
  1920x1080 (0x6b) 74.250MHz +HSync +VSync
        h: width  1920 start 2558 end 2602 total 2750 skew    0 clock  27.00KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  24.00Hz
  1920x1080i (0x6c) 74.176MHz +HSync +VSync Interlace
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.72KHz
        v: height 1080 start 1084 end 1094 total 1125           clock  59.94Hz
  1920x1080 (0x6d) 74.176MHz +HSync +VSync
        h: width  1920 start 2008 end 2052 total 2200 skew    0 clock  33.72KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  29.97Hz
  1920x1080 (0x6e) 74.176MHz +HSync +VSync
        h: width  1920 start 2558 end 2602 total 2750 skew    0 clock  26.97KHz
        v: height 1080 start 1084 end 1089 total 1125           clock  23.98Hz
  1280x720 (0x6f) 74.250MHz +HSync +VSync
        h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  45.00KHz
        v: height  720 start  725 end  730 total  750           clock  60.00Hz
  1280x720 (0x70) 74.250MHz +HSync +VSync
        h: width  1280 start 1720 end 1760 total 1980 skew    0 clock  37.50KHz
        v: height  720 start  725 end  730 total  750           clock  50.00Hz
  1280x720 (0x71) 74.176MHz +HSync +VSync
        h: width  1280 start 1390 end 1430 total 1650 skew    0 clock  44.96KHz
        v: height  720 start  725 end  730 total  750           clock  59.94Hz
  1440x576 (0x72) 54.000MHz -HSync -VSync
        h: width  1440 start 1464 end 1592 total 1728 skew    0 clock  31.25KHz
        v: height  576 start  581 end  586 total  625           clock  50.00Hz
  1440x480 (0x73) 54.054MHz -HSync -VSync
        h: width  1440 start 1472 end 1596 total 1716 skew    0 clock  31.50KHz
        v: height  480 start  489 end  495 total  525           clock  60.00Hz
  1440x480 (0x74) 54.000MHz -HSync -VSync
        h: width  1440 start 1472 end 1596 total 1716 skew    0 clock  31.47KHz
        v: height  480 start  489 end  495 total  525           clock  59.94Hz
  720x576 (0x75) 27.000MHz -HSync -VSync
        h: width   720 start  732 end  796 total  864 skew    0 clock  31.25KHz
        v: height  576 start  581 end  586 total  625           clock  50.00Hz
  720x576i (0x76) 13.500MHz -HSync -VSync Interlace
        h: width   720 start  732 end  795 total  864 skew    0 clock  15.62KHz
        v: height  576 start  580 end  586 total  625           clock  50.00Hz
  720x480 (0x77) 27.027MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.50KHz
        v: height  480 start  489 end  495 total  525           clock  60.00Hz
  720x480 (0x78) 27.000MHz -HSync -VSync
        h: width   720 start  736 end  798 total  858 skew    0 clock  31.47KHz
        v: height  480 start  489 end  495 total  525           clock  59.94Hz
  720x480i (0x79) 13.514MHz -HSync -VSync Interlace
        h: width   720 start  739 end  801 total  858 skew    0 clock  15.75KHz
        v: height  480 start  488 end  494 total  525           clock  60.00Hz
  720x480i (0x7a) 13.500MHz -HSync -VSync Interlace
        h: width   720 start  739 end  801 total  858 skew    0 clock  15.73KHz
        v: height  480 start  488 end  494 total  525           clock  59.94Hz
  640x480 (0x7b) 25.200MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.50KHz
        v: height  480 start  490 end  492 total  525           clock  60.00Hz
  640x480 (0x60) 25.175MHz -HSync -VSync
        h: width   640 start  656 end  752 total  800 skew    0 clock  31.47KHz
        v: height  480 start  490 end  492 total  525           clock  59.94Hz

I diff'ed the xrandr outputs -> no difference except for the timestamp.

About the windows and "stuff":
Sometimes when turning on or off the HDMI monitor, all windows, be it file manager windows, terminal windows, or windows of any other random apps (was just citing the filemanager windows as random example as these are the windows I have mostly open) will get displaced downwards by a little bit, maybe moved 10-20 pixels down on every workspace.
I just tried to reproduce it but this time nothing happened, lol. So I'm not sure under which circumstances they move exactly. But it is cumulative: Yesterday after some turning on/off while working, basically all windows ended up a lot more south on each workspace than where they started out so I had to drag them all manually back to where they belong, pretty annoying.

I'm using XFCE4 btw if it helps.
My usual setup is that when the external monitor is on I will move a VLC window set to fullscreen and "always visible on current workspace" onto the second monitor's part (right hand side) of the workspace, so I can watch a movie while doing other stuff, no matter to which workspace I'm currently switching on the laptop's internal monitor.

My goal currently is to make a script that does this VLC window-moving and -setting utilizing wmctrl (and possibly other tools if needed) automatically as soon as the monitor is switched on, so I don't have to do it manually every time. My most naive approach - which now seems out of the question - was to just have a script run on startup that checks xrandr output every second to test for 2nd monitor being switched on yet.

Last edited by millus (2020-07-29 09:19:36)

Offline

#12 2020-07-29 13:38:20

seth
Member
Registered: 2012-09-03
Posts: 15,750

Re: How to determine whether HDMI display is turned on or off?

The downward creeping might be a bug - the output might dis- and quickly re-appear and xfwm4 mess up the repositioning (moving the windows downwards when an output disappears doesn't seem to make much sense, it's probably a miscalculation by only half of the time invoking the titlebar margin for the topleft corner position)

You could see whether https://aur.archlinux.org/packages/x-on-resize/ picks up temporary output changes (and whether you can leverage them for your purposes)

Offline

#13 2020-07-29 15:18:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 23,934
Website

Re: How to determine whether HDMI display is turned on or off?

Agreed.  I suspect there must be two back-to-back root window changes.  Essentially the external display is detected triggering an expansion of the root window, but immediately disabled restoring the root window size.  Everything moving down a bit is a side effect.  If this is the case, the change *would* be reflected in xrandr output except that it is too brief and xrandr is not run at the right time.  So anything listening to ConfigureNotify events on the root window may pick it up (I believe that's what x-on-resize does).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#14 2020-07-29 15:29:57

Ropid
Member
Registered: 2015-03-09
Posts: 858

Re: How to determine whether HDMI display is turned on or off?

I experimented here a bit with "xev -root -event randr". It prints nothing when the monitor is turned off. It prints messages when the monitor turns back on. I ran this command line here that adds timestamps:

$ echo "$(date +%T): <-- start time"; xev -root -event randr | while read -r line; do echo "$(date +%T): $line"; done
17:20:29: <-- start time
17:20:45: 
17:20:45: RRNotify event, serial 18, synthetic NO, window 0x6cc,
17:20:45: subtype XRROutputPropertyChangeNotifyEvent
17:20:45: output DisplayPort-0, property EDID, timestamp 18791302, state Delete
17:20:45: 
17:20:45: RRScreenChangeNotify event, serial 18, synthetic NO, window 0x6cc,
17:20:45: root 0x6cc, timestamp 18593642, config_timestamp 18791509
17:20:45: size_index 65535, subpixel_order SubPixelUnknown
17:20:45: rotation RR_Rotate_0
17:20:45: width 2560, height 1440, mwidth 677, mheight 381
17:20:45: 
17:20:45: RRNotify event, serial 18, synthetic NO, window 0x6cc,
17:20:45: subtype XRROutputChangeNotifyEvent
17:20:45: output DisplayPort-0, crtc 79, mode 91
17:20:45: rotation RR_Rotate_0
17:20:45: connection RR_Disconnected, subpixel_order SubPixelUnknown
17:20:45: 
17:20:45: RRScreenChangeNotify event, serial 18, synthetic NO, window 0x6cc,
17:20:45: root 0x6cc, timestamp 18593642, config_timestamp 18791509
17:20:45: size_index 65535, subpixel_order SubPixelUnknown
17:20:45: rotation RR_Rotate_0
17:20:45: width 2560, height 1440, mwidth 677, mheight 381
17:20:45: 
17:20:45: RRNotify event, serial 18, synthetic NO, window 0x6cc,
17:20:45: subtype XRRCrtcChangeNotifyEvent
17:20:45: crtc 79, mode None, rotation RR_Rotate_0
17:20:45: x 0, y 0, width 0, height 0
17:20:45: 
17:20:45: RRNotify event, serial 18, synthetic NO, window 0x6cc,
17:20:45: subtype XRROutputChangeNotifyEvent
17:20:45: output DisplayPort-0, crtc None, mode None
17:20:45: rotation RR_Rotate_0
17:20:45: connection RR_Disconnected, subpixel_order SubPixelUnknown
17:20:46: 
17:20:46: RRScreenChangeNotify event, serial 29, synthetic NO, window 0x6cc,
17:20:46: root 0x6cc, timestamp 18791520, config_timestamp 18792259
17:20:46: size_index 65535, subpixel_order SubPixelUnknown
17:20:46: rotation RR_Rotate_0
17:20:46: width 2560, height 1440, mwidth 677, mheight 381
17:20:46: 
17:20:46: RRNotify event, serial 29, synthetic NO, window 0x6cc,
17:20:46: subtype XRROutputChangeNotifyEvent
17:20:46: output DisplayPort-0, crtc None, mode None
17:20:46: rotation RR_Rotate_0
17:20:46: connection RR_Connected, subpixel_order SubPixelUnknown
17:20:46: 
17:20:46: RRScreenChangeNotify event, serial 29, synthetic NO, window 0x6cc,
17:20:46: root 0x6cc, timestamp 18791520, config_timestamp 18792259
17:20:46: size_index 0, subpixel_order SubPixelUnknown
17:20:46: rotation RR_Rotate_0
17:20:46: width 2560, height 1440, mwidth 677, mheight 381
17:20:46: 
17:20:46: RRNotify event, serial 29, synthetic NO, window 0x6cc,
17:20:46: subtype XRRCrtcChangeNotifyEvent
17:20:46: crtc 79, mode 2560x1440_144, rotation RR_Rotate_0
17:20:46: x 0, y 0, width 2560, height 1440
17:20:46: 
17:20:46: RRNotify event, serial 29, synthetic NO, window 0x6cc,
17:20:46: subtype XRROutputChangeNotifyEvent
17:20:46: output DisplayPort-0, crtc 79, mode 2560x1440_144 (2560x1440)
17:20:46: rotation RR_Rotate_0
17:20:46: connection RR_Connected, subpixel_order SubPixelUnknown
^C

I turned off my monitor after that first "start time" message, then I waited fifteen seconds, then I turned it back on. It does not print anything when the monitor is off. The stuff it prints is when the monitor is turned back on.

Maybe this means there's nothing that can be done by looking for X events?

I also tried looking at the stuff that the open drivers shows in /sys/class/drm/. The driver exposes the monitor outputs over there and shows some info in text files. There's nothing to see in those files about the monitor being on or off, it's always the same contents for me with my single monitor. The file contents is this:

$ grep . /sys/class/drm/card0-*/{status,enabled,dpms}
/sys/class/drm/card0-DP-1/status:connected
/sys/class/drm/card0-DP-2/status:disconnected
/sys/class/drm/card0-DVI-D-1/status:disconnected
/sys/class/drm/card0-HDMI-A-1/status:disconnected
/sys/class/drm/card0-HDMI-A-2/status:disconnected
/sys/class/drm/card0-DP-1/enabled:enabled
/sys/class/drm/card0-DP-2/enabled:disabled
/sys/class/drm/card0-DVI-D-1/enabled:disabled
/sys/class/drm/card0-HDMI-A-1/enabled:disabled
/sys/class/drm/card0-HDMI-A-2/enabled:disabled
/sys/class/drm/card0-DP-1/dpms:On
/sys/class/drm/card0-DP-2/dpms:Off
/sys/class/drm/card0-DVI-D-1/dpms:Off
/sys/class/drm/card0-HDMI-A-1/dpms:Off
/sys/class/drm/card0-HDMI-A-2/dpms:Off

I tried running this command line both with the monitor on and off, and it's the exact same output both times.

Offline

#15 2020-08-07 17:27:18

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

I use KDE/Plasma and have very similar problem as @millus reported. Anyway I refers to my topic Is there a way to detect whether an external screen is in on/off mode?

@Ropid wrote:

I experimented here a bit with "xev -root -event randr ...

I think comnand:  grep . /sys/class/drm/card0-*/{status,enabled,dpms} shows only information if any display is enabled or disabled. I made some experiment to prove it. Check below.

* First output when my second display (projector) was disabled (enabled: "false" in configuration file related with kscreen)
$ grep . /sys/class/drm/card0-*/{status,enabled,dpms}

/sys/class/drm/card0-DP-1/status:disconnected
/sys/class/drm/card0-HDMI-A-1/status:connected
/sys/class/drm/card0-HDMI-A-2/status:connected
/sys/class/drm/card0-DP-1/enabled:disabled
/sys/class/drm/card0-HDMI-A-1/enabled:enabled
/sys/class/drm/card0-HDMI-A-2/enabled:disabled
/sys/class/drm/card0-DP-1/dpms:Off
/sys/class/drm/card0-HDMI-A-1/dpms:On
/sys/class/drm/card0-HDMI-A-2/dpms:Off

Second output when my second display (projector) was disabled (enabled: "true" in configuration file related with kscreen)
$ grep . /sys/class/drm/card0-*/{status,enabled,dpms}

/sys/class/drm/card0-DP-1/status:disconnected
/sys/class/drm/card0-HDMI-A-1/status:connected
/sys/class/drm/card0-HDMI-A-2/status:connected
/sys/class/drm/card0-DP-1/enabled:disabled
/sys/class/drm/card0-HDMI-A-1/enabled:enabled
/sys/class/drm/card0-HDMI-A-2/enabled:enabled
/sys/class/drm/card0-DP-1/dpms:Off
/sys/class/drm/card0-HDMI-A-1/dpms:On
/sys/class/drm/card0-HDMI-A-2/dpms:On

Note that, when I turned off second display (projector) then nothing changed in output.

I case your second check, so command: echo "$(date +%T): <-- start time"; xev -root -event randr | while read -r line; do echo "$(date +%T): $line"; done I get nothing no matter if (primary) monitor is turned on or off.

Finally I wonder if anyone discovered how to recognize if given display is turned on/off. The only one result gives me the same what @millus reported. I mean output from command: udevadm monitor .
[UPDATE]
Or actually this makes effect only for my primary monitor. When I turn on/off projector nothing happens. No events sent.

Last edited by piomiq (2020-08-07 19:31:49)

Offline

#16 2020-08-07 20:37:39

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

seth wrote:

The downward creeping might be a bug - the output might dis- and quickly re-appear and xfwm4 mess up the repositioning (moving the windows downwards when an output disappears doesn't seem to make much sense, it's probably a miscalculation by only half of the time invoking the titlebar margin for the topleft corner position)

You could see whether https://aur.archlinux.org/packages/x-on-resize/ picks up temporary output changes (and whether you can leverage them for your purposes)

I'm not sure how to use this tool. Below does nothing, reports nothing. I turned off and off again my display.

x-on-resize -a
x-on-resize -s :0

Offline

#17 2020-08-07 21:18:57

kokoko3k
Member
Registered: 2008-11-14
Posts: 1,993

Re: How to determine whether HDMI display is turned on or off?

Maybe one can use ddc protocol.
If the monitor answers, then it is powered on.

edit: totally untested.
edit: it is ddc, not dcc

Last edited by kokoko3k (2020-08-08 06:36:01)

Offline

#18 2020-08-07 23:05:41

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

millus wrote:

Thanks. Unfortunately there are no /dev/cec* devices so the command refuses to work.
However, somehow the notebook definitely notices when the monitor gets turned on or off, because some windows (eg VLC, but also file manager windows and other stuff) will change their locations accordingly.
So there is SOME kind of notification. I now tried

$ udevadm monitor

and all possible parameters such as property, kernel, udev or subsystem-match drm, and indeed there are a couple of "notifications" happening on power-on/off, but the problem is that they are completely indistinguishable. So the system must still have some other means to know when to move VLC from 2nd monitor to main monitor within the same "big" extended screen (3840x1080 ie 2x 1080p next to each other, defined in arandr).

Trying this you could get more human readable information:

sudo udevadm monitor --property

Offline

#19 2020-08-07 23:09:28

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

kokoko3k wrote:

Maybe one can use dcc protocol.
If the monitor answers, then it is powered on.

edit: totally untested.

How to use dcc protocol? Any example would be helpful.

Offline

#20 2020-08-08 04:09:45

Ropid
Member
Registered: 2015-03-09
Posts: 858

Re: How to determine whether HDMI display is turned on or off?

piomiq wrote:

How to use dcc protocol? Any example would be helpful.

There's a package "ddcutil" with a tool for DDC. The following command line finds monitors:

$ sudo ddcutil detect
Display 1
   I2C bus:             /dev/i2c-5
   EDID synopsis:
      Mfg id:           ACR
      Model:            XF270HU
      Serial number:    T78EE0048521
      Manufacture year: 2018
      EDID version:     1.4
   VCP version:         2.2

There's an argument "probe" to search for supported DDC features on a monitor. Looking through that list, there's a feature with code "0xd6" that's interesting to find out if the monitor is powered on or not:

$ sudo ddcutil getvcp d6
VCP code 0xd6 (Power mode                    ): DPM: On,  DPMS: Off (sl=0x01)

$ sudo ddcutil getvcp d6
VCP code 0xd6 (Power mode                    ): DPM: Off, DPMS: Off (sl=0x04)

The first output is the result I get with my monitor powered on. The second output is with the monitor off. It seems for my monitor here, I could use "ddcutil getvcp d6" to get the status.

There's a "--terse" parameter for help with scripting:

$ sudo ddcutil detect --terse
Display 1
   I2C bus:             /dev/i2c-5
   Monitor:             ACR:XF270HU:T78EE0048521

$ sudo ddcutil getvcp d6 --terse
VCP D6 SNC x01

For work with multiple monitors, there's a bunch of different parameters to target a certain one mentioned in "man ddcutil".

Offline

#21 2020-08-08 05:38:49

seth
Member
Registered: 2012-09-03
Posts: 15,750

Re: How to determine whether HDMI display is turned on or off?

You'd just run "x-on-resize", but it would likely only report sth. if the windows move downwards as well (assuming this is triggered by a transient change of the root window)

Offline

#22 2020-08-08 23:28:54

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

seth wrote:

You'd just run "x-on-resize", but it would likely only report sth. if the windows move downwards as well (assuming this is triggered by a transient change of the root window)

I run "x-on-resize" as user and with sudo. I was doing with windows many things like moving, minimizing, resizing, opening new applications even I did it with konsole (terminal emulator) where I started this application. In result "x-on-resize" reported absolutely nothing in standard output.
After I started "x-on-resize" any window(s) didn't downwards.

Offline

#23 2020-08-09 06:20:50

seth
Member
Registered: 2012-09-03
Posts: 15,750

Re: How to determine whether HDMI display is turned on or off?

After I started "x-on-resize" any window(s) didn't downwards.

That's the likely problem: there's a difference between yours and the OPs situation (where the system was claimed to show *some* reaction on the power state change of the output)

PS: please don't try to randomly sudo-fix stuff when it doesn't work™. You can easily make yurself a bad day.

Offline

#24 2020-08-10 10:09:42

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

seth wrote:

PS: please don't try to randomly sudo-fix stuff when it doesn't work™. You can easily make yurself a bad day.

I tried with sudo do to applications like ddcutil and ddccontrol (I mentioned about them in my original post: How to determine whether HDMI display is turned on or off?) needed higher privileges to work, so I thought it may help to get any output.

Maybe I will need to search some help in XOrg forum.

Offline

#25 2020-08-10 11:43:21

piomiq
Member
From: Warsaw, Poland
Registered: 2017-08-04
Posts: 25
Website

Re: How to determine whether HDMI display is turned on or off?

Ropid wrote:
piomiq wrote:

How to use dcc protocol? Any example would be helpful.

There's a package "ddcutil" with a tool for DDC. The following command line finds monitors:

I use following Linux kernel: 5.7.12-arch1-1. I loaded necessary 'i2c-dev' kernel modules and In result I got that communication failed

$ sudo ddcutil detect
Invalid display
I2C bus:             /dev/i2c-1
EDID synopsis:
Mfg id:           OTM
Model:            Optoma 1080P
Serial number:    72J6081111111
Manufacture year: 2017
EDID version:     1.3
DDC communication failed

Invalid display
I2C bus:             /dev/i2c-2
EDID synopsis:
Mfg id:           NEC
Model:            EA275WMi
Serial number:    74105467NB
Manufacture year: 2017
EDID version:     1.3
DDC communication failed

And command 'probe' reports that:

$ sudo ddcutil probe
Display not found

BTW. Command sudo ddccontrol -p, which is much faster than ddcutil, reports similar information like:

Probing for available monitors..I/O warning : failed to load external entity "/usr/share/ddccontrol-db/monitor/NEC2BA8.xml"
Document not parsed successfully.
.I/O warning : failed to load external entity "/usr/share/ddccontrol-db/monitor/OTM0027.xml"
Document not parsed successfully.
..
Detected monitors :
- Device: dev:/dev/i2c-2
DDC/CI supported: No
Monitor Name: VESA standard monitor
Input type: Digital
- Device: dev:/dev/i2c-1
DDC/CI supported: No
Monitor Name: VESA standard monitor
Input type: Digital
No monitor supporting DDC/CI available.

Seems my displays don't support DDC.

I wonder if there is any way to get to know if external display connected via HDMI is turned on or off.

Offline

Board footer

Powered by FluxBB