#/bin/bash #simple script to toggle secondary monitor output on or off #uses dcop from KDE 3.5 to send notify info #dcop messages are in Czech language #for use with "Input actions" in KDE control center is recommended to set "Keyboard shortcut -> Command/URL (simple)" and then write to text box "URL/command to execute": bash /home/user/.local/bin/toggle_vga.sh # ^^ without bash in text box it behaves as secondary output is disconnected #configuration of selected outputs regarding to output of command "xrandr" PRIMARY="DVI-I-1" SECONDARY="VGA-0" SECONDARY_MODE="1280x1024" #check if xrandr is installed if [ `which xrandr | wc -l` -gt 0 ] ; then # echo "xrandr is ok" # dcop knotify default notify toggle_vga "VGA přepínač" "xrandr je nainstalovaný" '' '' 16 0 #check if $SECONDARY output is connected if [ `xrandr | grep $SECONDARY | grep connected | wc -l` == 1 ] ; then # echo "$SECONDARY is connected" #check if $SECONDARY is enabled if [ `xrandr | grep $SECONDARY | grep connected | grep $SECONDARY_MODE | wc -l` == 1 ] ; then # echo "$SECONDARY is enabled with mode $SECONDARY_MODE" #disabling $SECONDARY dcop knotify default notify toggle_vga "VGA přepínač" "Vypínám výstup $SECONDARY" '' '' 16 0 sleep 3 xrandr --output $SECONDARY --off else # echo "$SECONDARY is disabled" #enabling $SECONDARY dcop knotify default notify toggle_vga "VGA přepínač" "Zapínám výstup $SECONDARY" '' '' 16 0 sleep 3 xrandr --output $SECONDARY --mode $SECONDARY_MODE --right-of $PRIMARY fi else # echo "$SECONDARY is not connected" dcop knotify default notify toggle_vga "VGA přepínač" "$SECONDARY je odpojeno" '' '' 16 0 fi else # echo "xrandr is not installed" dcop knotify default notify toggle_vga "VGA přepínač" "xrandr není nainstalovaný" '' '' 16 0 fi