Create a gist now

Instantly share code, notes, and snippets.

@jmrodri /addmode
Last active Aug 29, 2015

What would you like to do?
# 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