====== Howto: Shut down on lid close ======
The suspend mode from closing the lid still drains the battery quite quickly. The following hack shuts down rather than suspends when you close the lid.
When you close the lid on your EEE it runs /etc/acpi/lidbtn.sh
The script to shut down the EEE safely and quickly is called /sbin/fastshutdown.sh
So, if you comment out the line in /etc/acpi/lidbtn.sh that suspends on lid close and add a new line that runs this script, your eeepc will shutdown when the lid is closed.
===== Instructions =====
In the console type
sudo kwrite /etc/acpi/lidbtn.sh
You should see
#!/bin/sh
LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'`
if [ $LID_STATE = "closed" ] ; then
/etc/acpi/suspend2ram.sh
fi
exit 0
Add a hash mark before "/etc/acpi/suspend2ram.sh" (this line is now ignored but is still there in case you want to reverse this hack)
Add a new line "/sbin/fastshutdown.sh" as below
#!/bin/sh
LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'`
if [ $LID_STATE = "closed" ] ; then
# /etc/acpi/suspend2ram.sh
/sbin/fastshutdown.sh
fi
exit 0
Save and exit then close the lid to test.
See also [[howto:fastshutdown]]
==== Shutdown if on battery ====
Because suspend is still a desirable feature, you may still wish to use it when you are plugged in, and only shut down if you are on battery. (unplugging while in suspend WILL NOT cause the machine to shut down)
If you would like eeePC to **suspend** when you have the ac adapter plugged in and the lid closed, but **shut down** when using the battery edit /etc/acpi/lidbtn.sh to look like this:
#!/bin/sh
LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'`
PWR_STATE=`cat /proc/acpi/ac_adapter/AC0/state | awk '{print $2 }'`
if [ $LID_STATE = "closed" ] ; then
if [ $PWR_STATE = "off-line" ] ; then
/sbin/fastshutdown.sh ; else
/etc/acpi/suspend2ram.sh
fi
fi
exit 0
===== To Do Nothing On Closing The Lid =====
If you want you can simply leave the line commented out which will allow you to use your EEEPc with the lid closed and an external display (assuming you have a keyboard and mouse plugged in).
Just be careful! Your EEEPc will now do NOTHING when you close the lid!
===== Differing Behaviour Depending On Power Source =====
If you would like eeePC to **stay on** when you have the ac adapter plugged and the lid closed, but **suspend** when using the battery edit /etc/acpi/lidbtn.sh to look like this:
#!/bin/sh
LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'`
PWR_STATE=`cat /proc/acpi/ac_adapter/AC0/state | awk '{print $2 }'`
if [ $LID_STATE = "closed" ] ; then
if [ $PWR_STATE = "off-line" ] ; then
/etc/acpi/suspend2ram.sh
fi
fi
exit 0
===== Shutting off screen =====
If you'd rather just shut the screen off to save power use
#!/bin/sh
LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'`
if [ $LID_STATE = "closed" ] ; then
# /etc/acpi/suspend2ram.sh
su user -c "DISPLAY=:0 xset dpms force suspend"
elif [ $LID_STATE = "open" ] ; then
su user -c "DISPLAY=:0 xset dpms force on"
fi
as your /etc/acpi/lidbtn.sh
===== How to suspend with the power button =====
If you disabled suspend-on-close with the procedures above, you may wish to suspend in some cases.
* Fn-F1 suspends the computer
* Pressing the power button will give you a menu with suspend as an option (in simple desktop mode)
* In advanced desktop mode, go to start menu > Control Center > System administration > Login manager. Press the "Administrate" button if necessary, then go to the Shutdown tab and check "Display suspend button in logout window".
===== Behaviour of closing the lid when using external display =====
Forum member [[http://forum.eeeuser.com/profile.php?id=35873|Mue]] has posted an alternate lidbtn.sh in [[http://forum.eeeuser.com/viewtopic.php?id=38393|this thread]] that does the followings:
- shuts down if running on batteries;
- suspends if plugged in AC but with no external display;
- switches off the internal display and up the resolution on the external display if external display is selected;
- switches on the internal display and lowers the resolution of the external display to match the internal, if opening the lid while using external display.
#!/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
===== Behaviour when using external display and/or listening to music with lid closed =====
In the same [[http://forum.eeeuser.com/viewtopic.php?id=38393|thread]], forum member [[http://forum.eeeuser.com/profile.php?id=35873|Mue]] and [[http://forum.eeeuser.com/profile.php?id=1119|albkwan]] have worked out another lidbtn.sh that will normally shut down on lid close, except when:
1) An external display is selected --> Switches off the internal display only;
2) A music player (either Amarok, audacious, vlc, mplayer, mpg321 or xmms) is running --> Blank screen only.
This script is useful when you want to close the lid while listening to songs with earphones on the Eeepc, e.g. while walking in the street.
#!/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`
MUSIC_APP_STATE=`ps -A | egrep "amarokapp|audacious|wxvlc|mplayer|mpg321|xmms" | wc -l`
if [ $LID_STATE = "closed" ] ; then
# /etc/acpi/suspend2ram.sh
if [ $VGA_STATE = "1" ]; then
xrandr -display :0.0 --output LVDS --off
else
if [ $MUSIC_APP_STATE != "0" ]; then
if [ $LID_STATE = "closed" ] ; then
su user -c "DISPLAY=:0 xset dpms force suspend"
elif [ $LID_STATE = "open" ] ; then
su user -c "DISPLAY=:0 xset dpms force on"
fi
else
/sbin/fastshutdown.sh
fi
fi
fi
exit 0