#!/bin/sh # Copyright (C) 2007,2008 Krzysztof Kozlowski # License: GNU General Public License version 2 # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # version 2 as published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # Ostatnia zmiana: 12.03.2008 # # Turn on/off external VGA - RandR 1.2 # # # Settings: XRANDR="xrandr" VGA_OUTPUT="VGA" LVDS_OUTPUT="LVDS" TV_OUTPUT="TV" usage () { echo "Usage: $(basename $0) [-h|-s] [mode options] -h - print help -s - print status Mode options: -v - turn VGA output off, on (auto or exact mode) -l - turn LVDS output off, on (auto or exact mode) -t - turn TV output off, on (auto or exact mode) -f - change TV output format to NTSC or PAL You can obtain list of supported modes or TV formats with command: $(basename $0) -s" } if [ $# -lt 1 ]; then usage exit 127 fi XRANDR_COMMAND="" while getopts "t:f:v:l:hs" flag do case "$flag" in h ) usage && exit 0 ;; s ) $XRANDR --prop && exit 0 ;; v ) if [ "$OPTARG" == "on" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --output $VGA_OUTPUT --auto" elif [ "$OPTARG" == "off" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --output $VGA_OUTPUT --off" else XRANDR_COMMAND="$XRANDR_COMMAND --output $VGA_OUTPUT --mode $OPTARG" fi ;; l ) if [ "$OPTARG" == "on" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --output $LVDS_OUTPUT --auto" elif [ "$OPTARG" == "off" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --output $LVDS_OUTPUT --off" else XRANDR_COMMAND="$XRANDR_COMMAND --output $LVDS_OUTPUT --mode $OPTARG" fi ;; t ) if [ "$OPTARG" == "on" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --output $TV_OUTPUT --auto" elif [ "$OPTARG" == "off" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --output $TV_OUTPUT --off" else XRANDR_COMMAND="$XRANDR_COMMAND --output $TV_OUTPUT --mode $OPTARG" fi ;; f ) if [ "$OPTARG" == "NTSC" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --set TV_FORMAT NTSC-M" elif [ "$OPTARG" == "PAL" ]; then XRANDR_COMMAND="$XRANDR_COMMAND --set TV_FORMAT PAL" fi ;; esac done if [ "$XRANDR_COMMAND" != "" ]; then echo "Executing: $XRANDR $XRANDR_COMMAND ..." $XRANDR $XRANDR_COMMAND STATUS=$? else usage STATUS=127 fi exit $STATUS