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 ################################################################################
14 rm -f $RESOLUTION $ERROR
26 CURRENT_NUM=$(xrandr | awk '/\*/ {print $1}' | tr -d '*')
27 CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $2 $3 $4}')
30 for i in $(xrandr | awk {'print $2$3$4'} | grep "^[0-9]") ; do
31 STRING="$STRING $COUNTER $i"
36 dialog --title "$PN" --menu "Change X resolution via xrandr (current resolution: $CURRENT_RESOLUTION):" 0 0 0 $STRING 2>$RESOLUTION
39 (1) echo "Cancel pressed." ; exit 1 ;;
40 (255) echo "ESC pressed." ; exit 1 ;;
43 CHOSE=$(cat $RESOLUTION)
45 if [ "$CHOSE" = "$CURRENT_NUM" ] ; then
46 dialog --title "$PN" --msgbox "Chosen resolution corresponds to current resolution. No changes needed." 0 0
47 elif [ -n "$CHOSE" ] ; then
48 xrandr -s $CHOSE 2>$ERROR && \
49 dialog --title "$PN" --msgbox "Running xrandr with resolution was succesful." 0 0 || \
50 dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: `cat $ERROR`" 0 0