Skip to content

Instantly share code, notes, and snippets.

@jmrodri
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmrodri/cad187f6cb5d5ed832a3 to your computer and use it in GitHub Desktop.
Save jmrodri/cad187f6cb5d5ed832a3 to your computer and use it in GitHub Desktop.
# Copyright 2013 jesus m. rodriguez
#!/bin/sh
xres=$1
yres=$2
fullmodeline=$(cvt 1366 768 | grep Modeline | awk '{$1=""; print $0}')
modeline=$(echo $fullmodeline | awk '{print $1}')
monitors=$(xrandr | grep " connected " | awk '{print $1}')
matches=$(echo $monitors | gawk '{print NF}')
case "$matches" in
0)
echo "No matches found"
show=""
;;
1)
show=$monitors
;;
*)
echo
echo "Multiple matches found..."
i=1
for option in $monitors
do
echo "$i: $option"
i=`expr $i + 1`
done
echo "q: Quit"
echo
read -p "? " ans
if [ "q" == "$ans" ]; then
show=""
else
show=$(echo $monitors | gawk '{print $'$ans'}')
fi
;;
esac
if [ "" != "$show" ]; then
#xrandr --newmode $fullmodeline
xrandr --addmode $show $modeline
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment