Skip to content

Instantly share code, notes, and snippets.

@dragonauta
Created April 12, 2015 02:30
Show Gist options
  • Save dragonauta/d74865f613520470b1a5 to your computer and use it in GitHub Desktop.
Save dragonauta/d74865f613520470b1a5 to your computer and use it in GitHub Desktop.
Set dual head if monitor is connected to VGA output
#!/bin/bash
# Get state of VGA output: connected|disconnected
# you can get output's names with xrandr -q
VGA=$(xrandr -q | grep VGA1 | cut -f2 -d" ")
#
# Setting LVDS1 as primary (netbook display)
PRIMARY="--output LVDS1 --primary --mode 1024x600 --pos 0x0 --rotate normal"
#
# Setting VGA1 as secondary, placed right of LVDS1
SECONDARY="--output VGA1 --mode 1440x900 --pos 1024x0 --rotate normal"
#
# Setting off VGA1 output if no monitor connected
NOVGA="--output VGA1 --off"
#
# Is external display connected?
# then set as secondary, otherwise no VGA
if [[ "$VGA" == "connected" ]]
then
xrandr $PRIMARY $SECONDARY &
else
xrandr $PRIMARY $NOVGA &
fi
#
# aditionally, set backlight at 20%
xbacklight -set 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment