APMD(8) BSD System Manager's Manual APMD(8)NAMEapmd - run scripts on apm events
SYNOPSISapmd [-x] [-d script-dir] [-m mode] [-t threshold]
DESCRIPTION
The apmd daemon looks for apm events and runs the script associated with
the event, if it exists. The optional arguments are:
-d Specify the directory that the scripts are stored in. By default
this is /usr/libdata/apmd.
-m Set the APM mode to user or auto. By default the system runs in
auto mode. In this mode the system will automatically take ac-
tion on a user suspend or standby request. In user mode the sys-
tem will only report these to the APM logging socket. Setting
the mode to user will allow you to provide a meaningful
user_suspend_req script. The script should probably terminate
with apm suspend. The user_suspend_req script could then be used
to turn of PC Cards that have a problem if the system is suspend-
ed while they are active.
-t Set the "de-bounce" threshold to the specified number of mille-
seconds. The default is 2000 mille-seconds (2 seconds). If an
event is repeated within the specified threshold the repeated
event is suppressed.
-x Run in debug mode. Do not become a daemon.
SCRIPTS
Scripts are located in the directory /usr/libdata/apmd and must be one of
the following names:
battery
A battery changed status.
battery_0
Battery 0 changed status.
battery_1
Battery 1 changed status.
battery_2
Battery 2 changed status.
battery_3
Battery 3 changed status.
critical_resume
System resumed from critical suspend.
clock_change
The speed of the cycle counter has changed (Intel SpeedStep tech-
nology). The info field contains the new clock rate in cycles
per second.
critical_suspend
System suspending for a critical reason.
error_resume
System resuming from a failed suspend.
low_battery
Low battery warning.
normal_resume
System resumed.
standby_req
System requesting standby.
standby_resume
System resumed from standby.
status_change
Power status change.
suspend_req
System requesting suspend.
update_time
The time was updated.
user_standby_req
User requesting standby.
user_suspend_req
User requesting suspend.
other Any event not recognized.
For all but "other" scripts a single argument is passed which is an un-
signed integer in decimal containing the info field (the ECX register)
returned with the APM event. For "other" scripts the event number, in
hexadecimal, proceeds the info field.
EXAMPLE
The following example would be named /usr/libdata/apmd/normal_resume and
linked to /usr/libdata/apmd/critical_resume. This script is run when the
machine resumes from being in suspend mode. It attempts to regain an IP
address from a dhcp server using the ISC dhcp client.
#!/bin/sh
if [ -f /var/run/dhclient.pid ]
then
kill $(cat /var/run/dhclient.pid)
rm -f /var/run/dhclient.pid
sleep 2 # let PC Cards come back up
dhclient
else
exit 0
fi
The following script would named /usr/libdata/apmd/user_suspend_req when
the system is in user mode.
#!/bin/sh
csconfig -a down
sleep 2
apm suspend
The following script would named /usr/libdata/apmd/normal_resume when the
system is in user mode.
#!/bin/sh
csconfig -a up
SEE ALSOapm(8), apmstart(8), apmstop(8)AUTHOR
Steve Bellovin, ATT Research.
(The manual page was not provided by Mr. Bellovin and all mistakes and
shortcomings should not be attributed to him.)
BSDI BSD/OS September 19, 1999 3