I have tv on HDMI-0 and main display on DP-2.
When I turn off tv, some applications like image browser, still open on tv even when it is turned off.
I need sth like run automatically
xrandr --output HDMI-0 --off when I turn off tv.
And also bring back settings for
Joined Displays when I turn tv on.
For settings I mean to have tv on the left.
For some reason Ubuntu always treats tv as main display and that it is on the right.
I want tv to be on the left and not to be main display.
I tried https://github.com/phillipberndt/autorandr but it does not detect that tv is turned on. It probably just looks if there cable in hdmi?
This answer could provide one piece of the puzzle:
I tried to use
xset -q to get information if display is turned on, but it only shows my main monitor.
xrandr shows that tv is connected, but no info about it being powered off.
I see there is https://wiki.ubuntu.com/X/MonitorDetection but I don't know what to use.
sudo ddccontrol -p does not list my tv.
hwinfo does not list my tv.
So I have these two scripts:
to turn off:
#!/bin/bash intern=DP-2 extern=HDMI-0 xrandr --output "$extern" --auto --left-of "$intern" --output "$intern" --auto --primary
to turn on:
#!/bin/bash intern=DP-2 extern=HDMI-0 xrandr --output "$extern" --off
So now the question is how to detect that tv is turned off.
Now I see
xrandr -q gives different results when tv is turned off:
$ xrandr -q | grep "^HDMI-0" HDMI-0 connected (normal left inverted right x axis y axis) $ ~/bin/xrandr_auto_external_monitor.sh $ xrandr -q | grep "^HDMI-0" HDMI-0 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 1872mm x 1053mm
But probably I cannot get the event when tv is turned off manually?
when you manually switch of the the monitor, you cant catch it by windows (if there is no unusual driver interface for this), because all windows capabilities is connected to "power safe mode".