Skip to content
This repository

Workaround xrandr bug: "cannot find crtc for output" #16

Open
wants to merge 1 commit into from

1 participant

raztus
raztus

Disable all displays before attempting to call xrandr. This one-liner is probably very inefficient and exposes my inexperience with bash scripting. Feel free to modify the idea.

This is a workaround for an xrandr issue when two displays are connected and attempting to configure a different display, even when "off" is passed on the connected displays. See:
https://bugs.freedesktop.org/show_bug.cgi?id=22539 and
https://bugs.freedesktop.org/show_bug.cgi?id=29929

For example,

$ xrandr --output DP-1 --auto --output DP-2 --auto`
$ xrandr --output DP-1 --off --output DP-2 --off --output LVDS-1 --auto
# This will fail with error "cannot find crtc for output ..."

The workaround for this second command is instead to do:

xrandr --output DP-1 --off --output DP-2 --off && xrandr --output LVDS-1 --auto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. +7 0 autorandr
7 autorandr
@@ -164,6 +164,13 @@ config_equal() {
164 164 }
165 165
166 166 load_cfg_xrandr() {
  167 + # Disable all displays first. There is a bug in xrandr where trying to enable a different display
  168 + # when two displays are already attached gives the error "cannot find crtc for output" even
  169 + # when --off was passed to disable existing displays. If --off is called first as a separate
  170 + # command the crtcs are freed up for use.
  171 + # https://bugs.freedesktop.org/show_bug.cgi?id=22539
  172 + # https://bugs.freedesktop.org/show_bug.cgi?id=29929
  173 + $XRANDR | grep -P '(^[^ ]+) (dis)?connected' | sed -r 's/(^[^ ]+).*/--output \1 --off/' | xargs $XRANDR
167 174 sed 's!^!--!' "$1" | xargs $XRANDR
168 175 }
169 176

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.