How to determine which displays are enabled/disabled

displayx11xrandr

I am able to enable or disable my LVDS display using

xrandr --output LVDS --auto
xrandr --output LVDS --off

respectively, but how can I programmatically determine whether the display is enabled?

xrandr -q shows LVDS as connected regardless of enabled/disabled state.

Best Answer

following the comment of @derobert:

VGA-0 off:

VGA-0 connected (normal left inverted right x axis y axis)
1280x1024     60.02 +  75.02 
...

VGA-0 on:

VGA-0 connected 1280x1024+1680+0 (normal left inverted right x axis y axis) 380mm x 300mm
1280x1024     60.02*+  75.02 
...

so, you could check the return value of this quiet grep to see if it is actually enabled (you can of course reduce it to a more general regex)

grep -q 'VGA-0 connected 1280x1024+1680+0 (normal left inverted right x axis y axis) 380mm x 300' \
&& echo "connected AND enabled"

or, for your output (taken from comment above):

grep -q 'LVDS connected 1680x1050+0+0 (normal left inverted right x axis y axis) 331mm x 207mm' \
  && echo "connected AND enabled"
Related Question