Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/bin/bash
  2.  
  3. # LVDS1 is notebook display, and VGA1 is external CRT display. If you need, you may change
  4. # it key words to another.
  5.  
  6.  
  7. TMPF="/tmp/swmons.tmp"
  8. VGA_STATE=`xrandr | grep 'VGA1' | awk '{print $2}'`
  9.  
  10. # by default, LVDS1 is always connected - we check only VGA
  11. if [ "$VGA_STATE" = "disconnected" ]; then
  12.     DISPLAY=:0.0 /usr/bin/sudo -u drag0n -s "(/bin/echo -e "'\\n\\n'"Second monitor not connected. | osd_cat -o 15 -A center -f -*-terminus-medium-*-*-*-14-*-*-*-*-*-*-u -c green -d 2)"
  13.     exit 1
  14. fi
  15.  
  16. # display screen menu
  17. DISPLAY=:0.0 /usr/bin/sudo -u drag0n -s "Xdialog --menu 'Select monitor configuration' 10 40 5 '1m' 'One monitor' '2m' 'Dual monitors'" &> $TMPF
  18. SEL_CONF=`cat $TMPF`
  19. rm -f $TMPF
  20.  
  21. if [ "$SEL_CONF" = "1m" ]; then
  22.     DISPLAY=:0.0 /usr/bin/sudo -u drag0n -s "/usr/bin/xrandr --fb 1280x800 --output LVDS1 --primary --mode 1280x800 --pos 0x0 --output VGA1 --off"
  23. elif [ "$SEL_CONF" = "2m" ]; then
  24.     DISPLAY=:0.0 /usr/bin/sudo -u drag0n -s "/usr/bin/xrandr --fb 2048x768 --output LVDS1 --primary --mode 1024x768 --pos 0x0 --output VGA1 --mode 1024x768 --pos 1024x0"
  25. fi
  26.  
  27. exit 0