Advertisement
Guest User

Xrandr Display Configurator

a guest
Nov 27th, 2011
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.14 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Lists available ports (ones with something connected) in dialog
  4. dialog --backtitle "Display Options" --radiolist "Select port:" 12 40 4 `xrandr | grep -w "connected" | sed 's/ .*//g' | awk '{print NR " " $0 " off"}' | sed ':a;N;$!ba;s/\n/ /g'` 2>/tmp/disp_port
  5.  
  6. # Sets relevant variables
  7. number=`cat /tmp/disp_port`
  8. EXT=`xrandr | grep -w "connected" | sed 's/ .*//g' | head -$number | tac | head -1`
  9. IN="LVDS1"
  10.  
  11. # Lists display options
  12. dialog --backtitle "Desktop Options" --radiolist "Select one:" 12 40 4 1 "Extend" on 2 "Clone" off 3 "Switch display" off 4 "Normal display" off 2>/tmp/disp_opt
  13. disp_opt=`cat /tmp/disp_opt`
  14.  
  15. # Sets display option
  16. if [ "$disp_opt" = 1 ]; then
  17. xrandr --output $EXT --off --output $IN --auto &&
  18. xrandr --output $IN --auto --output $EXT --auto --right-of $IN
  19. elif [ "$disp_opt" = 2 ]; then
  20. xrandr --output $EXT --off --output $IN --auto &&
  21. xrandr --output $EXT --auto
  22. elif [ "$disp_opt" = 3 ]; then
  23. xrandr --output $EXT --off --output $IN --auto &&
  24. xrandr --output $IN --off --output $EXT --auto
  25. elif [ "$disp_opt" = 4 ]; then
  26. xrandr --output $EXT --off --output $IN --auto
  27. fi
  28.  
  29. clear
  30. exit
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement