I want to be able to disable and enable specific screen from command line so that the layout of all screens (their relative positions to each other) would be the same after re-enabling screen like it was before first disabling screen.
I have two identical screens side by side, HDMI-A-1
on the left and DP-1
on the right (it’s set as the primary one):
$ kscreen-doctor -o | grep -e Output -e Geometry
Output: 1 HDMI-A-1
Geometry: 0,0 1920x1200
Output: 2 DP-1
Geometry: 1920,0 1920x1200
When I run kscreen-doctor output.HDMI-A-1.disable
to disable the left one and then kscreen-doctor output.HDMI-A-1.enable
to enable it back both show the same content instead of extended desktop like it was before disabling and enabling the left screen.
I guess it’s due to changed geometry of the right screen after disabling/enabling the left screen (the new value of 0,0
instead of the previous value of 1920,0
):
$ kscreen-doctor -o | grep -e Output -e Geometry
Output: 1 HDMI-A-1
Geometry: 0,0 1920x1200
Output: 2 DP-1
Geometry: 0,0 1920x1200
The fact that disabling and enabling one screen (HDMI-A-1
) changes geometry of another screen (DP-1
) is a little surprising but on the other hand, after disabling the left screen, the right one still having geometry of 1920,0
i.e. being positioned to the right of no longer existing left screen does not indeed make sense.
The question is why does it work this way using kscreen-doctor
when doing the same from Display Settings works as expected i.e. the relative position of screens is not lost and after re-enabling the left screen it’s still on the left of the other one like before disabling?
Where does Display Settings store information on geometry so that it could be restored after re-enabling a screen?
I’m aware that the solution in this case is to use kscreen-doctor output.HDMI-A-1.enable output.DP-1.position.1920,0
when re-enabling the left screen to also set position of the right screen back to where it was before disabling the left screen.
(Btw, could someone add screen(s)
tag)