rendered paste body#!/bin/bash
ACTIONDIR=/etc/acpi/actions/
source /etc/acpi/actions/common.sh
arg_group=${1/\/*/}
arg_action=${1/*\//}
arg_device=$2
arg_parameter1=$3
arg_parameter2=$4
log "lid event: $1; $2; $3; $4"
GOVERNOR=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
#
# If lid is open, do not do anything
#
# if [ "$1" == "button/lid" ] && grep -q open /proc/acpi/button/lid/LID/state; then
# log "lid event while lid open. Ignored.";
# exit 0;
# fi;
$HWCLOCK --localtime --systohc
#
# change to console (otherwise fglrx is screwed up)
FGCONSOLE=$($CONSOLE)
$CHVT 1
#
# register battery usage stats for fun
FILENAME=$($DATE +'%FT%R')
FILENAME="/tmp/battery-data/$FILENAME"
# echo "modules:" >> "$FILENAME"
# $LSMOD >> "$FILENAME"
echo "before:" >> "$FILENAME"
$DATE +'%s' >> "$FILENAME"
$CAT /sys/devices/platform/smapi/BAT0/remaining_capacity >> "$FILENAME"
#
# flush disk cache, if suspend2ram hangs
$SYNC
# a bit of powersaving
# disable wake-on-lan -- maybe not necessary when disabled in BIOS?
$ETHTOOL -s eth0 wol d
#
# This doubles the power drain on 2.6.17-r5
$MODPROBE -r ehci_hcd
# good night
echo -n "mem" > /sys/power/state
# Restore USB2.0
$MODPROBE ehci_hcd
echo "after:" >> "$FILENAME"
$DATE +'%s' >> "$FILENAME"
$CAT /sys/devices/platform/smapi/BAT0/remaining_capacity >> "$FILENAME"
# readjust the clock
$HWCLOCK --hctosys --localtime
#
# force HD APM off (almost)
$HDPARM -B200 /dev/sda
#
# change back to whichever console we had (fglrx hack)
$CHVT "$FGCONSOLE"
echo "$GOVERNOR" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor