From: tachylatus Date: Thu, 4 Jul 2013 10:44:43 +0000 (+0200) Subject: Workaround xrandr bug: "cannot find crtc for output" - efficient solution X-Git-Tag: 1.0~156 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=83355f418b766be94a49c51a4f2cf77362148b0e;hp=393917156558574f0c3e07cccb8ea8c30cfc457f;p=deb_pkgs%2Fautorandr.git Workaround xrandr bug: "cannot find crtc for output" - efficient solution xrandr will typically fail when switching outputs, if the maximum number is already enabled. This patch will cause xrandr to be called twice: - First invocation will only disable outputs, freeing up CRTCs - Second invocation will only enable outputs --- diff --git a/autorandr b/autorandr index e38fcad..0872536 100755 --- a/autorandr +++ b/autorandr @@ -174,7 +174,28 @@ config_equal() { } load_cfg_xrandr() { - sed 's!^!--!' "$1" | xargs $XRANDR + # sed 1: Prefix arguments with "--" + # sed 2: Merge arguments into one line per output + # sed 3: Merge into two lines, all --off outputs in the first one + sed 's/^/--/' "$1" | sed -e ' + :START + /\n--output/{P;D} + s/\n/ / + N;bSTART' | sed -e ' + ### First line + / --off/{ + G + # Merge if next line contains --off + s/\n\([^\n]* --off\)/ \1/ + h + $!d;b + } + ### Last line + H;x + # Merge if previous line contains --mode + s/\(--mode [^\n]*\)\n/\1 / + h + $!d' | xargs -L 1 $XRANDR } load_cfg_disper() {