updated on Sun Jan 8 12:02:35 UTC 2012
[aur-mirror.git] / acpi-eee / display.sh
blob530c33e539356554bdd33f74d7743b0bf8749a9b
1 #!/bin/sh
2 #This script is run when Display toggle button (Fn-F5) is pressed.
4 OUTPUT_DISPLAY_MODE="clone"
6 source /etc/acpi/eee.conf
8 if [ -S /tmp/.X11-unix/X0 ]; then
9 export DISPLAY=:0
10 user=$(who | grep "vc/7" | awk '{ if ($(NF) == "(:0)") print $1 }')
11 if [ "$user" = "" ];
12 then
13 logger "Could not verify user for X:"
14 logger $(who)
15 logger "Falling back to XUSER: $XUSER"
16 user="$XUSER"
17 else
18 logger "Found X session user: $user"
20 XAUTHORITY=/home/$user/.Xauthority
21 [ -f $XAUTHORITY ] && export XAUTHORITY
22 else
23 logger "X not probably running, lets launch the command anyway"
24 user="$XUSER"
27 action="$1"
28 # if we are being called directly from an ACPI script, do a little hack
29 if [ "$action" = "hotkey" ]; then
30 case $3 in
31 00000030) action="lvds" ;;
32 00000031) action="vga" ;;
33 00000032) action="both" ;;
34 *) echo "unknown hotkey $3!"; exit 1 ;;
35 esac
38 case $action in
39 lvds)
40 xrandr --output LVDS --preferred --output VGA --off
42 both)
43 if [ "$OUTPUT_DISPLAY_MODE" == "clone" ]; then
44 xrandr --output LVDS --preferred --output VGA --preferred
45 else
46 xrandr --output LVDS --mode 800x480 --output VGA --"$OUTPUT_DISPLAY_MODE" LVDS
49 vga)
50 xrandr --output LVDS --off --output VGA --preferred
52 *)
53 echo "Usage: $0 [lvds|both|vga]";
54 exit 1
56 esac