Advertisement
Guest User

Untitled

a guest
May 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. main=LVDS1
  4. a=VGA1
  5. b=HDMI1
  6. dir=left
  7.  
  8. function on {
  9. echo Switching $1 on
  10. xrandr --output $1 --auto --$dir-of $main
  11. }
  12.  
  13. function off {
  14. echo Switching $1 off
  15. xrandr --output $1 --off
  16. }
  17.  
  18. function check {
  19. xrandr | egrep "$1 connected" >/dev/null
  20. echo $?
  21. }
  22.  
  23. outa=$(check $a)
  24. outb=$(check $b)
  25.  
  26. [[ $outa -ne 0 ]] && off $a
  27. [[ $outb -ne 0 ]] && off $b
  28.  
  29. [[ $outa -ne 0 && $outb -ne 0 ]] && exit
  30. [[ $outa -eq 0 && $outb -ne 0 ]] && on $a && exit
  31. [[ $outa -ne 0 && $outb -eq 0 ]] && on $b && exit
  32.  
  33. xrandr | egrep "$a connected [0-9]+" >/dev/null
  34. outa=$?
  35. xrandr | egrep "$b connected [0-9]+" >/dev/null
  36. outb=$?
  37.  
  38. if [[ $outa -eq 0 ]]; then
  39. off $a
  40. on $b
  41. else
  42. off $b
  43. on $a
  44. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement