From: Phillip Berndt Date: Sun, 8 Mar 2015 17:14:06 +0000 (+0100) Subject: Prevent, in apply_configuration, a xrandr call that disables all screens X-Git-Tag: 1.0~71 X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fautorandr.git;a=commitdiff_plain;h=29cd564aeb1d081e8fe7cf1ceba41e7b642fe9f6 Prevent, in apply_configuration, a xrandr call that disables all screens See pull request #20 --- diff --git a/autorandr.py b/autorandr.py index 9dea362..2baa1b1 100755 --- a/autorandr.py +++ b/autorandr.py @@ -462,6 +462,13 @@ def apply_configuration(configuration, dry_run=False): else: disable_outputs = disable_outputs[-1:] + # If disable_outputs still has more than one output in it, one of the xrandr-calls below would + # disable the last two screens. This is a problem, so if this would happen, instead disable only + # one screen in the first call below. + if len(disable_outputs) > 0 and len(disable_outputs) % 2 == 0: + # In the context of a xrandr call that changes the display change, `--query' should do nothing + disable_outputs.insert(0, ['--query']) + # Enable the remaining outputs in pairs of two operations operations = disable_outputs + enable_outputs for index in range(0, len(operations), 2):