Attachment '45custom_xrandr-settings.txt'

Download

   1 # If an external monitor is connected, place it with xrandr
   2 
   3 function determineLocation() {
   4   local extLoc=$1
   5   local intOut=$2
   6 
   7   case "$extLoc" in
   8     left|LEFT) 
   9       OPTIONS="--left-of $intOut"
  10       ;;
  11     right|RIGHT)
  12       OPTIONS="--right-of $intOut"
  13       ;;
  14     top|TOP|above|ABOVE)
  15       OPTIONS="--above $intOut"
  16       ;;
  17     bottom|BOTTOM|below|BELOW)
  18       OPTIONS="--below $intOut"
  19       ;;
  20     *)
  21       OPTIONS="--above $intOut"
  22       ;;
  23   esac
  24 }
  25 
  26 function setupMonitor() {
  27   local intOut=$1
  28   local extOut=$2
  29   local options=$3
  30 
  31   xrandr | grep $extOut | grep " connected "
  32 
  33   if [ $? -eq 0 ]; then
  34     #printf "INTERNAL_OUTPUT: %s, EXTERNAL_OUTPUT: %s, OPTIONS: %s\n" "$intOut" "$extOut" "$options"
  35     xrandr --output $intOut --auto --output $extOut --auto $options
  36     # Alternative command in case of trouble:
  37     # (sleep 2; xrandr --output $intOut --auto --output $extOut --auto $options) &
  38   else
  39     #printf "INTERNAL_OUTPUT: %s, OPTIONS: %s\n" "$intOut" "$options"
  40     xrandr --output $intOut --auto --output $options --off
  41   fi
  42 }
  43 
  44 
  45 INTERNAL_OUTPUT="LVDS1"
  46 
  47 # External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
  48 EXTERNAL_OUTPUT="VGA1"
  49 # EXTERNAL_LOCATION may be one of: left, right, above, or below
  50 EXTERNAL_LOCATION="above"
  51 
  52 determineLocation "$EXTERNAL_LOCATION" "$INTERNAL_OUTPUT"
  53 setupMonitor "$INTERNAL_OUTPUT" "$EXTERNAL_OUTPUT" "$OPTIONS"
  54 
  55 # External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
  56 EXTERNAL_OUTPUT="HDMI1"
  57 # EXTERNAL_LOCATION may be one of: left, right, above, or below
  58 EXTERNAL_LOCATION="right"
  59 
  60 determineLocation "$EXTERNAL_LOCATION" "$INTERNAL_OUTPUT"
  61 setupMonitor "$INTERNAL_OUTPUT" "$EXTERNAL_OUTPUT" "$OPTIONS"

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.