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 # shellcheck disable=SC2086
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 # shellcheck disable=SC2015
50 xrandr -s "$CHOSE" 2>"$ERROR" && \
51 dialog --title "$PN" --msgbox "Running xrandr with resolution was succesful." 0 0 || \
52 dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: $(cat "$ERROR")" 0 0