4

I'm writing a script in which I need to switch between two displays, but I can't find a way to get the information about the current active output.

Pretty much like this:

if Display0 is off and Display1 is on
     turn off Display1
     turn on Display0
else if Display1 is off and Display0 is on
     turn off Display0
     turn on Display1

The piece I'm missing is the first line: how do I know which display is currently active?

Note: xrandr -q doesn't help because it always print that both displays are "connected" regardless of whether the output is directed on Display0 or Display1, not sure if this is a bug.

oidualc
  • 1,453

1 Answers1

0
xrandr | awk '/\ connected/ && /[[:digit:]]x[[:digit:]].*+/{print $1}'

here is the command to find which monitors are on, which is your original question.

Also I wrote the script to switch between monitors: Swap between monitor display modes using shortcut

hyamanieu
  • 248