Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. EXTERNAL_OUTPUT=$(xrandr | grep ' connected' | awk '{print $1}' | sed -n '2p')
  4. INTERNAL_OUTPUT=$(xrandr | grep ' connected' | awk '{print $1}' | sed -n '1p')
  5.  
  6. # if we don't have a file, start at zero
  7. if [ ! -f "/tmp/monitor_mode.dat" ] ; then
  8.   monitor_mode="all"
  9.  
  10. # otherwise read the value from the file
  11. else
  12.   monitor_mode=`cat /tmp/monitor_mode.dat`
  13. fi
  14.  
  15. if [ $monitor_mode = "all" ]; then
  16.         monitor_mode="EXTERNAL"
  17.         xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --auto
  18. elif [ $monitor_mode = "EXTERNAL" ]; then
  19.         monitor_mode="INTERNAL"
  20.         xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
  21. elif [ $monitor_mode = "INTERNAL" ]; then
  22.         monitor_mode="CLONES"
  23.         xrandr --output $INTERNAL_OUTPUT --output $EXTERNAL_OUTPUT --auto --same-as $INTERNAL_OUTPUT
  24. else
  25.         monitor_mode="all"
  26.         xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto --left-of $INTERNAL_OUTPUT
  27. fi
  28. echo "${monitor_mode}" > /tmp/monitor_mode.dat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement