updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / acpi-eeepc-generic / acpi-eeepc-generic-toggle-resolution.sh
blob1036095acaa06e5ca5664d5e4c56522c5de833c7
1 #!/bin/bash
2 # Copyright 2009 Nicolas Bigaouette
3 # This file is part of acpi-eeepc-generic.
4 # http://code.google.com/p/acpi-eeepc-generic/
5 #
6 # acpi-eeepc-generic is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # acpi-eeepc-generic is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with acpi-eeepc-generic. If not, see <http://www.gnu.org/licenses/>.
19 . /etc/acpi/eeepc/acpi-eeepc-generic-functions.sh
21 tmp_xrandr="$EEEPC_VAR/lvds-modes"
23 if [ -e "$tmp_xrandr" ]; then
24 LVDS_XRANDR=$(cat $tmp_xrandr)
25 else
26 LVDS_XRANDR=$(xrandr > $tmp_xrandr)
29 LVDS_MODES=$(cat $tmp_xrandr | grep -F -e LVDS -A 12 | grep [0-9]x[0-9] | grep -v -e LVDS | awk '{printf $1" "}')
30 LVDS_CURRENT=$(cat $tmp_xrandr | grep -F -e LVDS -A 12 | grep -F -e [0-9]x[0-9] -e "*" | awk '{print $1}')
32 function toggle_resolution {
33 for mode in $LVDS_MODES $LVDS_MODES; do
34 if [ "$mode" = "$LVDS_CURRENT" ]; then
35 NEXT=1;
36 elif [ "$NEXT" = "1" ]; then
37 xrandr -s $mode
38 eeepc_notify "Changing resolution to \"$mode\"" video-display
39 echo $mode > $EEEPC_VAR/resolution_saved
40 exit
42 done
45 function restore_resolution {
46 if [ -e "$EEEPC_VAR/resolution_saved" ]; then
47 RESOLUTION=$(cat $EEEPC_VAR/resolution_saved)
48 xrandr -s $RESOLUTION
49 eeepc_notify "Changing resolution back to \"$RESOLUTION\"" video-display
53 case $1 in
54 restore)
55 restore_resolution
58 toggle_resolution
60 esac