#!/bin/bash

# PowerManagement Control Script
# This script will be called on certain events from a
# powermanagement daemon with two arguments. The first
# argument contains the command and the second the
# currently active power source.
#
# arg $1: powersave     minimum power consumption
#         performance   maximum performance
#         sleep         prepare for sleep
#         wakeup        recovering from sleep
#
# arg $2: ac            running on ac power
#         battery       running on battery
#
# Options for this scripts will be kept in the central
# configuration file ../config. Variables for each script
# will be introduced by a special unique prefix.

# name        : pmac_g3
# prefix      : PMACG3_
# author      : 
# description : hardware related stuff for G3 Powerbooks
# requirements: wakebay from pmud-utils package
# limitations : not needed for G3 Pismo
#
# --- end of public part -- don't change below this line ---

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

# source configuration
. config

case "$1" in
  powersave)
    ;;
  performance)
    ;;
  sleep)
    ;;
  wakeup)
    [ -f /proc/sys/dev/cdrom/info ] && {
      device=$(cat /proc/sys/dev/cdrom/info | (
      IFS=":"
      while read var val
      do
        [ "$var" = "drive name" ] && {
	  echo $val
	  break
	}
      done
      ))
      [ ! -z "$device" ] && {
        wakebay /dev/${device}
      }
    }
    ;;
esac

exit 0
