4

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.

2
  • I don't have an LVDS display to disable on this machine to check, but I suggest xrandr > on; xrandr --output LVDS --off; xrandr > off; diff -dbU3 on off. Add in --verbose if needed. I'm pretty sure xrandr actually tells you.
    – derobert
    Sep 18 '14 at 7:35
  • diff on off: <<< LVDS connected 1680x1050+0+0 (normal left inverted right x axis y axis) 331mm x 207mm\n 1680x1050 59.88*+ >>> LVDS connected (normal left inverted right x axis y axis)\n> 1680x1050 59.88 +. YEP!
    – Colin
    Sep 18 '14 at 14:52
1

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"
3
  • thanks, xdpyinfo only gives one screen for some reason, but see derobert's comment
    – Colin
    Sep 18 '14 at 15:01
  • @colin see update
    – Sebastian
    Sep 18 '14 at 15:14
  • More general: xrandr | grep -q "$display connected [0-9]" where $display is your dispay's ID (e.g. LVDS in OP's case)
    – raphinesse
    Feb 5 '18 at 20:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.