sohotcall

xrandr swap two displays

Aug 30th, 2022
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.48 KB | None | 0 0
  1. #!/usr/bin/bash
  2. xrandr | grep -E '^(VGA|HDMI).* connected' | while read line; do
  3.     port=`echo $line | sed -E 's/([^ ]+) .*/\1/'`
  4.     isLeft=`echo $line | grep -E '\+0\+0'`
  5.     if [[ $isLeft ]]; then
  6.         if [[ $left ]]; then
  7.             right=$left
  8.         fi
  9.         left=$port
  10.     else
  11.         right=$port
  12.     fi
  13.     if [[ $left && $right ]]; then
  14.         xrandr --output $left --right-of $right
  15.     fi
  16. done
  17.  
  18. #You must connect two displays only (no less, no more).
  19. #They should have same resolution.
  20. #Tips: Set up hot keys.
  21.  
Advertisement
Add Comment
Please, Sign In to add comment