2 # Filename: grml-resolution
3 # Purpose: change X resolution via a simple menu frontend
4 # Authors: Florian Keller <florian.keller@zuerich.ch>, (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 # Latest change: Thu May 04 23:13:39 CEST 2006 [mika]
8 ################################################################################
15 rm -f $RESOLUTION $ERROR
27 CURRENT_NUM=$(xrandr | awk '/\*/ {print $1}' | tr -d '*')
28 CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $2 $3 $4}')
31 for i in $(xrandr | awk {'print $2$3$4'} | grep "^[0-9]") ; do
32 STRING="$STRING $COUNTER $i"
37 dialog --title "$PN" --menu "Change X resolution via xrandr (current resolution: $CURRENT_RESOLUTION):" 0 0 0 $STRING 2>$RESOLUTION
40 (1) echo "Cancel pressed." ; exit 1 ;;
41 (255) echo "ESC pressed." ; exit 1 ;;
44 CHOSE=$(cat $RESOLUTION)
46 if [ "$CHOSE" = "$CURRENT_NUM" ] ; then
47 dialog --title "$PN" --msgbox "Chosen resolution corresponds to current resolution. No changes needed." 0 0
48 elif [ -n "$CHOSE" ] ; then
49 xrandr -s $CHOSE 2>$ERROR && \
50 dialog --title "$PN" --msgbox "Running xrandr with resolution was succesful." 0 0 || \
51 dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: `cat $ERROR`" 0 0