Skip to content

Instantly share code, notes, and snippets.

@ninetails
Last active November 28, 2019 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninetails/5eedcf764039632648212a456c21c125 to your computer and use it in GitHub Desktop.
Save ninetails/5eedcf764039632648212a456c21c125 to your computer and use it in GitHub Desktop.

Set ordered outputs to extend side-by-side

xrandr | grep " connected " | awk '{ print$1 }' | awk '{if (prev) printf " --output %s --auto --right-of %s", $0, prev;else printf "xrandr --output %s --auto --primary", $0;prev=$0}' | xargs -L 1 -I {} sh -c "{}"

i3 menu

# display menu
set $mode_display (e) extend (m) mirror
mode "$mode_display" {
        bindsym e exec --no-startup-id "xrandr | grep \\" connected \\" | awk '{ print$1 }' | awk '{if (prev) printf \\" --output %s --auto --right-of %s\\", $0, prev;else printf \\"xrandr --output %s --auto --primary\\", $0;prev=$0}' | xargs -L 1 -I {} sh -c \\"{}\\"", mode "default"
        bindsym m exec --no-startup-id "xrandr | grep \\" connected \\" | awk '{ print$1 }' | awk '{if (prev) printf \\" --output %s --auto --pos 0x0\\", $0, prev;else printf \\"xrandr --output %s --auto --primary --pos 0x0\\", $0;prev=$0}' | xargs -L 1 -I {} sh -c \\"{}\\"", mode "default"

        # back to normal: Enter or Escape
        bindsym Return mode "default"
        bindsym Escape mode "default"
}

bindsym $mod+shift+d mode "$mode_display"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment