xref: /freebsd/usr.sbin/apmd/README (revision d50a71bdd882717df3f41dadd84ffc28f3466a1a)
1FreeBSD apmd Package Release Notes (19990711 version)
2
31. What is "apmd"?
4==================
5
6The apmd package provides a means of handling various APM events from
7userland code.  Using apmd.conf, the apmd(8) configuration file, you
8can select the APM events to be handled from userland and specify the
9commands for a given event, allowing APM behaviour to be configured
10flexibly.
11
12
132. How to install the apmd package
14==================================
15
162.1 Making the apmd control device file
17---------------------------------------
18
19apmd(8) uses the new special device file /dev/apmctl.  This should be
20created as follows:
21
22# cd /dev
23# mknod apmctl c 39 8
24
252.2 Applying the kernel patch and building a new kernel
26-------------------------------------------------------
27
28The next step is to apply the patch against the sys source tree.
29Go to the source directory (eg. /usr/src/ or /usr/PAO3/src/) and run
30the patch command as follows:
31
32# gzip -cd [somewhere]/apmd-sys-R320.diff | patch
33
34For PAO3 users, the patch file name would be apmd-sys-PAO3.diff
35instead of apmd-sys-R320.diff.  After this step has completed
36successfully, build and install a new kernel and reboot your system.
37
382.3 Making the apmd program
39---------------------------
40
41Go to src/usr.sbin/ and extract the apmd tarball as follows:
42
43# tar xzpvf [somewhere]/apmd-usr.sbin.tar.gz
44
45Before doing a make all, you need to copy apm_bios.h in the sys source
46tree to /usr/include/machine/ first:
47
48# cp /sys/i386/include/apm_bios.h /usr/include/machine/
49
50Then do the build and install steps in the apmd directory:
51
52# cd src/usr.sbin/apmd
53# make depend all install
54
552.4 Setting up the configuration file and userland script
56---------------------------------------------------------
57
58In src/usr.sbin/apm/etc/ there are example configuration and userland
59script files which are invoked automatically when the APM BIOS informs
60apmd of an event, such as suspend request.  Copy these files to
61/etc/ as follows:
62
63# cp src/usr.sbin/apm/etc/* /etc/
64
65
663. Running the apmd daemon program
67==================================
68
69To run apmd(8) in background mode, simply type ``apmd''.
70
71# apmd
72
73To make a running apmd reload /etc/apmd.conf, send a SIGHUP signal to
74the apmd(8) process.
75
76# kill -HUP [apmd pid]
77or
78# killall -HUP apmd
79
80apmd has some command line options.  For the details, please
81refer to the manpage of apmd.
82
834. Configuration file
84=====================
85
86The structure of the apmd configuration file is quite simple.  For
87example:
88
89apm_event SUSPENDREQ {
90	exec "sync && sync && sync";
91	exec "sleep 1";
92	exec "zzz";
93}
94
95Will cause apmd to recieve the APM event SUSPENDREQ (which may be
96posted by an LCD close), run the sync command 3 times and wait for a
97while, then execute zzz (apm -z) to put the system in the suspend
98state.
99
1004.1 The apm_event keyword
101-------------------------
102`apm_event' is the keyword which indicates the start of configuration for
103each events.
104
1054.2 APM events
106--------------
107
108If you wish to execute the same commands for different events, the
109event names should be delimited by a comma.  The following are valid
110event names:
111
112o Events ignored by the kernel if apmd is running:
113
114STANDBYREQ
115SUSPENDREQ
116USERSUSPENDREQ
117BATTERYLOW
118
119o Events passed to apmd after kernel handling:
120
121NORMRESUME
122CRITRESUME
123STANDBYRESUME
124POWERSTATECHANGE
125UPDATETIME
126
127
128Other events will not be sent to apmd.
129
1304.3 command line syntax
131-----------------------
132
133In the example above, the three lines begining with `exec' are commands
134for the event.  Each line should be terminated with a semicolon.  The
135command list for the event should be enclosed by `{' and `}'. apmd(8)
136uses /bin/sh for double-quotation enclosed command execution, just as
137with system(3).  Each command is executed in order until the end of
138the list is reached or a command finishes with a non-zero status code.
139apmd(8) will report any failed command's status code via syslog(3)
140and will then reject the request event posted by APM BIOS.
141
1424.4 Built-in functions
143----------------------
144
145You can also specify apmd built-in functions instead of command lines.
146A built-in function name should be terminated with a semicolon, just as
147with a command line.
148The following built-in functions are currently supported:
149
150o reject;
151
152  Reject last request posted by the APM BIOS.  This can be used to reject a
153  SUSPEND request when the LCD is closed and put the system in a STANDBY
154  state instead.
155
156
157
1585. EXAMPLES
159===========
160
161Sample configuration commands include:
162
163apm_event SUSPENDREQ {
164	exec "/etc/rc.suspend";
165}
166
167apm_event USERSUSPENDREQ {
168	exec "sync && sync && sync";
169	exec "sleep 1";
170	exec "apm -z";
171}
172
173apm_event NORMRESUME, STANDBYRESUME {
174	exec "/etc/rc.resume";
175}
176
177# resume event configuration for serial mouse users by
178# reinitializing a moused(8) connected to a serial port.
179#
180#apm_event NORMRESUME {
181#	exec "kill -HUP `cat /var/run/moused.pid`";
182#}
183
184# suspend request event configuration for ATA HDD users:
185# execute standby instead of suspend.
186#
187#apm_event SUSPENDREQ {
188#	reject;
189#	exec "sync && sync && sync";
190#	exec "sleep 1";
191#	exec "apm -Z";
192#}
193
194
1956. Call for developers
196======================
197
198The initial version of apmd(8) was implemented primarily to test the
199kernel support code and was ALPHA quality.  Based on that code, the
200current version was developed by KOIE Hidetaka <hide@koie.org>.
201However, we're still looking around for interesting new features and
202ideas, so if you have any thoughts, please let us know.
203Documentation is also sparse, and the manpage have just written.
204If you wish to collaborate on this work, please e-mail me:
205iwasaki@freebsd.org.
206
207
208June 1, 1999
209Created by: iwasaki@FreeBSD.org
210Edited by: jkh@FreeBSD.org
211           nick@foobar.org
212
213$Id: README,v 1.1.2.2 1999/06/08 09:01:47 koie Exp $
214