Sweep over our manual pages and remove .Pp before a .Bd or .Bl without
[games.git] / usr.sbin / apmd / apmd.8
1 .\" Copyright (c) 1999 Mitsuru IWASAKI <iwasaki@FreeBSD.org>
2 .\" Copyright (c) 1999 KOIE Hidetaka <koie@suri.co.jp>
3 .\" Copyright (c) 1999 Yoshihiko SARUMARU Aq <mistral@imasy.or.jp>
4 .\" Copyright (c) 1999 Norihiro Kumagai <kuma@nk.rim.or.jp>
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)apmd.8      1.1 (FreeBSD) 6/28/99
29 .\" $FreeBSD: src/usr.sbin/apmd/apmd.8,v 1.7.2.7 2003/03/11 21:13:47 trhodes Exp $
30 .\" $DragonFly: src/usr.sbin/apmd/apmd.8,v 1.4 2008/05/02 02:05:07 swildner Exp $
31 .\"
32 .Dd June 28, 1999
33 .Dt APMD 8
34 .Os
35 .Sh NAME
36 .Nm apmd
37 .Nd Advanced Power Management monitor daemon
38 .Sh SYNOPSIS
39 .Nm
40 .Op Fl d
41 .Op Fl f file
42 .Op Fl v
43 .Sh DESCRIPTION
44 The
45 .Nm
46 utility
47 monitors the occurrence of the specified Advanced Power Management
48 .Pq Tn APM
49 events and, if one of the events occurs, it executes the sequence of
50 commands corresponding to the event.  Only the events specified in the
51 configuration file are notified to
52 .Nm ;
53 all other events are ignored.  For each event posted by the APM BIOS,
54 .Nm
55 invokes the sequence of commands specified in the configuration file.
56 When
57 .Nm
58 is running with monitoring suspend/standby requests,
59 the kernel will not process those requests.
60 Therefore, if you wish action to be taken when these events
61 occur, you need to explicitly configure the appropriate commands or
62 built-in functions in the configuration file.
63 .Pp
64 The
65 .Nm
66 utility recognizes the following runtime options:
67 .Bl -tag -width -f_file
68 .It Fl d
69 Starts in debug mode.  This causes
70 .Nm
71 to execute in the foreground instead of in daemon mode.
72 .It Fl f Ar file
73 Specifies a different configuration file
74 .Ar file
75 to be used in place of the default
76 .Pa /etc/apmd.conf .
77 .It Fl v
78 Verbose mode.
79 .El
80 .Pp
81 When
82 .Nm
83 starts, it reads the configuration file
84 .Pa ( /etc/apmd.conf
85 as default)
86 and notifies the set of events to be monitored to the APM device driver.
87 When it terminates, the APM device driver automatically cancels
88 monitored events.
89 .Pp
90 If the
91 .Nm
92 process receives a SIGHUP, it will reread its configuration file and
93 notify the APM device driver of any changes to its configuration.
94 .Pp
95 The
96 .Nm
97 utility uses the device
98 .Pa /dev/apmctl
99 to issue
100 .Xr ioctl 2
101 requests for monitoring events and for controlling the APM system.
102 This device file is opened exclusively, so only a single
103 .Nm
104 process can be running at any time.
105 .Pp
106 When
107 .Nm
108 receives an APM event, it forks a child process to execute the
109 commands specified in the configuration file and then continues
110 listening for more events.  The child process executes the commands
111 specified, one at a time and in the order that they are listed.
112 .Pp
113 While
114 .Nm
115 is processing the command list for SUSPEND/STANDBY requests, the APM kernel
116 device driver issues notifications to APM BIOS once per second so that the
117 BIOS knows that there are still some commands pending, and that it should not
118 complete the request just yet.
119 .Pp
120 The
121 .Nm
122 utility creates the file
123 .Pa /var/run/apmd.pid ,
124 and stores its process
125 id there.
126 This can be used to kill or reconfigure
127 .Nm .
128 .Sh CONFIGURATION FILE
129 The structure of the
130 .Nm
131 configuration file is quite simple.  For example:
132 .Bd -literal
133 apm_event SUSPENDREQ {
134        exec "sync && sync && sync";
135        exec "sleep 1";
136        exec "zzz";
137 }
138 .Ed
139 .Pp
140 will cause
141 .Nm
142 to receive the APM event
143 .Ql SUSPENDREQ
144 (which may be posted by an LCD close), run the
145 .Ql sync
146 command 3 times and wait for a while, then execute
147 .Nm zzz ( Ns Nm apm Fl z )
148 to put the system in the suspend state.
149 .Bl -bullet
150 .It
151 The  apm_event keyword
152 .Bd -ragged -offset indent
153 .Ql apm_event
154 is the keyword which indicates the start of configuration for
155 each events.
156 .Ed
157 .It
158 APM events
159 .Bd -ragged -offset indent
160 If you wish to execute the same commands for different events, the
161 event names should be delimited by a comma.  The following are
162 valid event names:
163 .Bl -item
164 .It
165 - Events ignored by the kernel if
166 .Nm
167 is running:
168 .Pp
169 .Bl -tag -width USERSUSPENDREQ -compact -offset indent
170 .It STANDBYREQ
171 .It USERSTANDBYREQ
172 .It SUSPENDREQ
173 should include sync in the command list,
174 .It USERSUSPENDREQ
175 should include sync in the command list,
176 .It BATTERYLOW
177 only zzz should be specified in the command list.
178 .El
179 .It
180 - Events passed to
181 .Nm
182 after kernel handling:
183 .Pp
184 .Bl -tag -width USERSUSPENDREQ -compact -offset indent
185 .It NORMRESUME
186 .It CRITRESUME
187 .It STANDBYRESUME
188 .It POWERSTATECHANGE
189 .It UPDATETIME
190 .It CAPABILITIESCHANGE
191 .El
192 .Pp
193 Other events will not be sent to
194 .Nm .
195 .El
196 .Ed
197 .It
198 command line syntax
199 .Bd -ragged -offset indent
200 In the example above, the three lines beginning with
201 .Ql exec
202 are commands for the event.
203 Each line should be terminated with a semicolon.
204 The command list for the event should be enclosed by
205 .Ql {
206 and
207 .Ql } .
208 The
209 .Nm
210 utility uses
211 .Pa /bin/sh
212 for double-quotation enclosed command execution, just as with
213 .Xr system 3 .
214 Each command is executed in order until the end of
215 the list is reached or a command finishes with a non-zero status code.
216 The
217 .Nm
218 utility will report any failed command's status code via
219 .Xr syslog 3
220 and will then reject the request event posted by the APM BIOS.
221 .Ed
222 .It
223 Built-in functions
224 .Bd -ragged -offset indent
225 You can also specify
226 .Nm
227 built-in functions instead of command lines.
228 A built-in function name should be terminated with a semicolon,
229 just as with a command line.
230 The following built-in functions are currently supported:
231 .Bl -item
232 .It
233 - reject:
234 .Bd -ragged -offset indent
235 Reject last request posted by APM BIOS.  This can be used to reject
236 a SUSPEND request when the LCD is closed and put the system in a
237 STANDBY state instead.
238 .Ed
239 .El
240 .Ed
241 .El
242 .Sh FILES
243 .Bl -tag -width /etc/apmd.conf -compact
244 .It Pa /etc/apmd.conf
245 .It Pa /dev/apmctl
246 .It Pa /var/run/apmd.pid
247 .El
248 .Sh EXAMPLES
249 Sample configuration commands include:
250 .Bd -literal
251 apm_event SUSPENDREQ {
252         exec "/etc/rc.suspend";
253 }
254
255 apm_event USERSUSPENDREQ {
256         exec "sync && sync && sync";
257         exec "sleep 1";
258         exec "apm -z";
259 }
260
261 apm_event NORMRESUME, STANDBYRESUME {
262         exec "/etc/rc.resume";
263 }
264
265 # resume event configuration for serial mouse users by
266 # reinitializing a moused(8) connected to a serial port.
267 #
268 #apm_event NORMRESUME {
269 #       exec "kill -HUP `cat /var/run/moused.pid`";
270 #}
271 #
272 # suspend request event configuration for ATA HDD users:
273 # execute standby instead of suspend.
274 #
275 #apm_event SUSPENDREQ {
276 #       reject;
277 #       exec "sync && sync && sync";
278 #       exec "sleep 1";
279 #       exec "apm -Z";
280 #}
281 .Ed
282 .Sh SEE ALSO
283 .Xr apm 4 ,
284 .Xr apm 8
285 .Sh HISTORY
286 The
287 .Nm
288 utility appeared in
289 .Fx 3.3 .
290 .Sh AUTHORS
291 .An Mitsuru IWASAKI Aq iwasaki@FreeBSD.org
292 .An KOIE Hidetaka Aq koie@suri.co.jp
293 .Pp
294 Some contributions made by
295 .An Warner Losh Aq imp@FreeBSD.org ,
296 .An Hiroshi Yamashita Aq bluemoon@msj.biglobe.ne.jp ,
297 .An Yoshihiko SARUMARU Aq mistral@imasy.or.jp ,
298 .An Norihiro Kumagai Aq kuma@nk.rim.or.jp ,
299 .An NAKAGAWA Yoshihisa Aq nakagawa@jp.FreeBSD.org ,
300 and
301 .An Nick Hilliard Aq nick@foobar.org .