#!/bin/bash
#
# This script is invoked by pbbuttonsd to configure the system for a
# given power level. The script gets two arguments:
# $1 = 'profile', 'sleep' or 'wakeup'
# $2 = 'ac' or 'battery'
#
# The first argument tells the script that power profile has changed,
# the machine is preparing for sleep or has waken up again.
# The second argument contains the currently active power source.

PATH=/bin:/sbin:/usr/bin:/usr/sbin

case "$1" in
  lowbat)
    wall "Low battery - system will go down in $2 minutes"
    ;;
  emergency)
    shutdown -h now
    ;;
  *)
    run-parts --arg="$1" --arg="$2" active
    ;;
esac

exit 0
