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.
echo $DISPLAY
? when both display connected and also when 1th is connected and then when 2th connected. (each result in separate line). thank yoou – αғsнιη Dec 27 '14 at 11:33echo $DISPLAY
returns:0
regardless of the connected display – oidualc Dec 27 '14 at 11:49DISPLAY=:0 xrandr | grep primary
say? – muru Dec 27 '14 at 12:01DVI-0 connected primary...
when DVI-0 is primary according tognome-control-center display
,DVI-1 connected primary...
when DVI-1 is primary. This information though, still doesn't tell me if the non-primary is either on or off – oidualc Dec 27 '14 at 12:13xset
? – muru Dec 27 '14 at 12:14gedit ~/.config/monitors.xml
in body of your question.(connect both display) – αғsнιη Dec 27 '14 at 12:33<primary>yes</primary>
tag between and if it possible making answer for your question. if you see the content of that file you will see what monitors is primary and which on is not. see the example of that in this answer – αғsнιη Dec 27 '14 at 13:30<primary>yes</primary>
are deleted. However this doesn't help, because in order to extract this information from the file and put it in the script I'd need an xml parser, this would be overkill! – oidualc Dec 27 '14 at 13:59