====== Eee PC Customizations ====== Some Eee PC customizations via shell script * Disable suspend to ram when AC adapter is plugged in and the lid is closed. * 30 minute timeout, after which the computer is suspended anyways * If the lid is closed and the AC adapter is unplugged, then suspend to ram is run. * Lock the screen if the lid is closed unless you're at home (checked via wireless connection) * Lock the screen if the screen blanking button is pressed unless you're at home #!/bin/sh # Jeff Brown # October 26, 2010 # Version: 1.0 # http://photonicsguy.ca/eeepc/ # Set your your ESSID for your house or a known safe location here SAFE_ESSID='CHANGE_ME_TO_HOME_AP_NAME' # Screensaver program SSAVER="/usr/bin/kdesktop_lock --forcelock" ######################################################################## IW_STATE=`/sbin/iwconfig 2> /dev/null | grep ESSID | awk '{print $4}'` IW_LINK=`cat /proc/net/wireless | grep ra0 | awk '{printf "%.0f", $3}'` PROG=`echo -n $SSAVER |awk '{print $1}'` if pgrep -f $PROG ; then echo "$PROG already running, exiting..." exit fi if [ $IW_STATE = "ESSID:\"$SAFE_ESSID\"" -a $IW_LINK -gt 5 ]; then echo "Connected to $IW_STATE" if [ "$1" = "lock" ]; then echo "Locking screen per user request." xset -display :0.0 dpms force off $SSAVER & fi else echo "Disconnected from $IW_STATE (Trying to match $SAFE_ESSID)" xset -display :0.0 dpms force off $SSAVER & fi #!/bin/sh LID_STATE=`cat /proc/acpi/button/lid/LID/state | awk '{print $2 }'` AC_STATE=`cat /proc/acpi/ac_adapter/AC0/state | awk '{print $2}'` if [ $LID_STATE = "closed" ] ; then if [ $AC_STATE = "off-line" ]; then /etc/acpi/suspend2ram.sh else # Added line /etc/acpi/suspendtimeout.sh & # Added line /etc/acpi/screenlock.sh # Added line fi # Added line else # Added line /etc/acpi/cancelsuspend.sh # Added line fi exit 0 # Optionally you can specify the placeholder %e. It will pass # through the whole kernel event message to the program you've # specified. event=ac_adapter action=/etc/acpi/lidbtn.sh #!/bin/sh # Jeff Brown # October 27, 2010 # Version: 1.0 # http://photonicsguy.ca/eeepc/ DELAY=30m # Delay SUSPEND=/etc/acpi/suspend2ram.sh # Program to call after timeout ################################################################## NAME=`basename $0` if [ $NAME = "suspendtimeout.sh" ]; then sleep $DELAY $SUSPEND elif [ $NAME = "cancelsuspend.sh" ]; then PID=`pgrep suspendtimeout` if [ $? != 0 ]; then echo "Error, can't find suspendtimeout" else kill -TERM $PID if [ $? != 0 ]; then echo "ERROR, can't terminate suspendtimeout, process $PID" fi fi fi exit 0