Created
January 10, 2013 10:03
-
-
Save kelnos/4500899 to your computer and use it in GitHub Desktop.
script to toggle ext monitor on and offf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -ex | |
stuff=$(xrandr | grep -v -E '^eDP1' | grep ' connected') && have_ext=yes || have_ext=no | |
if [ "$have_ext" = "no" ]; then | |
# just make sure it's off | |
for op in $(xrandr | awk '/disconnected/ { print $1 }'); do | |
xrandr --output $op --off | |
done | |
else | |
# FIXME: if i somehow have more than one ext monitor connected... | |
op=$(echo "$stuff" | cut -d' ' -f1) | |
echo "$stuff" | grep -q -E '[[:digit:]]+x[[:digit:]]+' && connected=yes || connected=no | |
if [ "$connected" = "yes" ]; then | |
xrandr --output $op --off | |
else | |
xrandr --output $op --preferred --right-of eDP1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment