updated zshrc

This commit is contained in:
arcan1s
2014-06-24 16:06:54 +04:00
parent 7611aff35b
commit 7dd9e66722
2 changed files with 55 additions and 39 deletions

54
zshrc
View File

@ -297,35 +297,51 @@ pack () {
fi fi
} }
# function to contorl xrandr # functions to contorl xrandr
# EXAMPLE: projctl 1024x768 # EXAMPLE: projctl 1024x768
projctl() { projctl() {
if [ $1 ]; then MONITORS="$(xrandr | grep connected | cut -d ' ' -f 1 | tr '\n' ' ')"
if [ $1 = "-h" ]; then echo "Available monitors are: ${MONITORS}"
echo "Usage: projctl [ off/resolution ]" FIRSTMON="LVDS1"
return SECONDMON="VGA1"
fi RESOLUTION="1366x768"
until [ -z $1 ]; do
if [ $1 = "off" ]; then case "$1" in
echo "Disable VGA1" "-h" | "--help" ) echo "Usage: projctl [ off/resol ] [ -o MON | --output MON ]" && exit 0 ;;
xrandr --output VGA1 --off --output LVDS1 --mode 1366x768 "-o" | "--output" ) [ -z "$2" ] || SECONDMON="$2" && shift ;;
* ) RESOLUTION="$1" ;;
esac
shift
done
if [[ "${RESOLUTION}" == "off" ]]; then
echo "Disable ${SECONDMON}"
xrandr --output ${FIRSTMON} --mode ${RESOLUTION} --output ${SECONDMON} --off
else else
echo "Using resolution: $1" echo "Using resolution: ${RESOLUTION}"
xrandr --output VGA1 --mode $1 --output LVDS1 --mode $1 xrandr --output ${FIRSTMON} --mode ${RESOLUTION} --output ${SECONDMON} --mode ${RESOLUTION}
fi
else
echo "Using default resolution"
xrandr --output VGA1 --mode 1366x768 --output LVDS1 --mode 1366x768
fi fi
} }
twinmon() { twinmon() {
MONITORS="$(xrandr | grep connected | cut -d ' ' -f 1 | tr '\n' ' ')"
echo "Available monitors are: ${MONITORS}"
FIRSTMON="LVDS1" FIRSTMON="LVDS1"
SECONDMON="VGA1" SECONDMON="VGA1"
if [[ $1 == "off" ]]; then MODE="on"
xrandr --output $FIRSTMON --auto --primary --output $SECONDMON --off until [ -z $1 ]; do
case "$1" in
"-h" | "--help" ) echo "Usage: twinmon [ off ] [ -o MON | --output MON ]" && exit 0 ;;
"-o" | "--output" ) [ -z "$2" ] || SECONDMON="$2" && shift ;;
"off" ) MODE="off" ;;
esac
shift
done
if [[ "${MODE}" == "off" ]]; then
echo "Disable ${SECONDMON}"
xrandr --output ${FIRSTMON} --auto --primary --output ${SECONDMON} --off
else else
xrandr --output $FIRSTMON --auto --primary --output $SECONDMON --auto --left-of $FIRSTMON echo "Enable ${SECONDMON}"
xrandr --output ${FIRSTMON} --auto --primary --output ${SECONDMON} --auto --left-of ${FIRSTMON}
fi fi
} }