#!/bin/sh # # This script is invoked by pbbuttonsd to configure the system for a # given power level. The script gets three arguments: # The first and the the third argument belong together. The first # argument is a command and the third a corresponding argument. Not # each of the commands have a corresponding argument. The following # table shows possible combinations: # # $1 $3 # 'powersave' | power policies transfered to slave # 'custom' | scripts # 'performance' | # 'suspend' 'ram' prepare for suspend to RAM (sleep) # 'disk' prepare for suspend to disk # 'shutdown' prepare for system shutdown # 'resume' 'ram' after wakeup from suspend to RAM # 'disk' theoretically, not used yet # 'emergency' battery is critically low -> shutdown. # 'shutdown' user initiated a system shutdown. # 'cover-open' 'open' cover has been opened # 'cover-close' 'close' cover has been closed # # 'cover-open' and 'cover-closed' will only be called if no other # suspend script is going to be called or sleep is not supported # on this machine. The argument for this command is a future # investment. # # The second argument contains the current powersource of the laptop # 'ac' # 'battery' # # The commands 'emergency' and 'shutdown' are handled directly. All # other commands will be transfered to the slave scripts which hopefully # will do the work. PATH=/bin:/sbin:/usr/bin:/usr/sbin # Logging is done by the pbbuttonsd daemon. case "$1" in emergency) hibernate #shutdown -h now "Low battery - system will go down now!" ;; shutdown) shutdown -h now "User requested shutdown - system will go down now!" ;; *) cd `dirname $0` PATH=$PATH:$PWD [ -d ${1}.d ] && run-parts --arg="$1" --arg="$2" --arg="$3" ${1}.d run-parts --arg="$1" --arg="$2" --arg="$3" event.d ;; esac