This is what it does:
If I'm running on batteries, it shuts down.
If I'm plugged in, but with no external monitor, it suspends.
If I'm plugged in with an external monitor, it switches off the internal screen, and up the resolution on the external monitor.
If I open the lid and I'm using the external monitor it switched on the internal monitor, and lowers the resolution of the external monitor to match the internal.
#!/bin/sh
LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'`
AC0_STATE=`cat /proc/acpi/ac_adapter/AC0/state | awk '{print $2 }'`
VGA_STATE=`xrandr --prop -display :0.0 | grep "VGA connected [0-9]" | wc -l`
LVDS_STATE=`xrandr --prop -display :0.0 | grep "LVDS connected [0-9]" | wc -l`
if [ $LID_STATE = "closed" ]; then
if [ $AC0_STATE = "on-line" ]; then
if [ $VGA_STATE = "1" ]; then
if [ $LVDS_STATE = "1" ]; then
xrandr -display :0.0 --output LVDS --off
xrandr -display :0.0 --output VGA --mode 1024x768
fi
else
/etc/acpi/suspend2ram.sh
fi
else
/sbin/fastshutdown.sh
fi
else
if [ $VGA_STATE = "1" ]; then
xrandr -display :0.0 --output LVDS --mode 1024x600
xrandr -display :0.0 --output VGA --mode 1024x600
fi
fi
exit 0
Edited by Mue, 02 August 2008 - 09:02 PM.











