]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.sbin/apmd/apmd.8
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 <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$
30 .\"
31 .Dd June 28, 1999
32 .Dt APMD 8 i386
33 .Os
34 .Sh NAME
35 .Nm apmd
36 .Nd Advanced Power Management monitor daemon
37 .Sh SYNOPSIS
38 .Nm
39 .Op Fl d
40 .Op Fl f file
41 .Op Fl s
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.
51 Only the events specified in the
52 configuration file are notified to
53 .Nm ;
54 all other events are ignored.
55 For each event posted by the APM BIOS,
56 .Nm
57 invokes the sequence of commands specified in the configuration file.
58 When
59 .Nm
60 is running with monitoring suspend/standby requests,
61 the kernel will not process those requests.
62 Therefore, if you wish action to be taken when these events
63 occur, you need to explicitly configure the appropriate commands or
64 built-in functions in the configuration file.
65 .Pp
66 The
67 .Nm
68 utility recognizes the following runtime options:
69 .Bl -tag -width f_file
70 .It Fl d
71 Starts in debug mode.
72 This causes
73 .Nm
74 to execute in the foreground instead of in daemon mode.
75 .It Fl f Ar file
76 Specifies a different configuration file
77 .Ar file
78 to be used in place of the default
79 .Pa /etc/apmd.conf .
80 .It Fl s
81 Causes
82 .Nm
83 to simulate a POWERSTATECHANGE event when a power state change is detected
84 (AC_POWER_STATE) but the bios of the laptop does not report it.
85 This enables you to do things like dimming the LCD backlight when you unplug
86 the power cord.
87 .It Fl v
88 Verbose mode.
89 .El
90 .Pp
91 When
92 .Nm
93 starts, it reads the configuration file
94 .Pa ( /etc/apmd.conf
95 as default)
96 and notifies the set of events to be monitored to the APM device driver.
97 When it terminates, the APM device driver automatically cancels
98 monitored events.
99 .Pp
100 If the
101 .Nm
102 process receives a
103 .Dv SIGHUP ,
104 it will reread its configuration file and
105 notify the APM device driver of any changes to its configuration.
106 .Pp
107 The
108 .Nm
109 utility uses the device
110 .Pa /dev/apmctl
111 to issue
112 .Xr ioctl 2
113 requests for monitoring events and for controlling the APM system.
114 This device file is opened exclusively, so only a single
115 .Nm
116 process can be running at any time.
117 .Pp
118 When
119 .Nm
120 receives an APM event, it forks a child process to execute the
121 commands specified in the configuration file and then continues
122 listening for more events.
123 The child process executes the commands
124 specified, one at a time and in the order that they are listed.
125 .Pp
126 While
127 .Nm
128 is processing the command list for SUSPEND/STANDBY requests, the APM kernel
129 device driver issues notifications to APM BIOS once per second so that the
130 BIOS knows that there are still some commands pending, and that it should not
131 complete the request just yet.
132 .Pp
133 The
134 .Nm
135 utility creates the file
136 .Pa /var/run/apmd.pid ,
137 and stores its process
138 id there.
139 This can be used to kill or reconfigure
140 .Nm .
141 .Sh CONFIGURATION FILE
142 The structure of the
143 .Nm
144 configuration file is quite simple.
145 For example:
146 .Bd -literal
147 apm_event SUSPENDREQ {
148        exec "sync && sync && sync";
149        exec "sleep 1";
150        exec "zzz";
151 }
152 .Ed
153 .Pp
154 will cause
155 .Nm
156 to receive the APM event
157 .Ql SUSPENDREQ
158 (which may be posted by an LCD close), run the
159 .Ql sync
160 command 3 times and wait for a while, then execute
161 .Nm zzz ( Ns Nm apm Fl z )
162 to put the system in the suspend state.
163 .Bl -bullet
164 .It
165 The apm_event keyword
166 .Bd -ragged -offset indent
167 .Ql apm_event
168 is the keyword which indicates the start of configuration for
169 each event.
170 .Ed
171 .It
172 APM events
173 .Bd -ragged -offset indent
174 If you wish to execute the same commands for different events, the
175 event names should be delimited by a comma.
176 The following are
177 valid event names:
178 .Bl -item
179 .It
180 - Events ignored by the kernel if
181 .Nm
182 is running:
183 .Pp
184 .Bl -tag -width USERSUSPENDREQ -compact -offset indent
185 .It STANDBYREQ
186 .It USERSTANDBYREQ
187 .It SUSPENDREQ
188 should include sync in the command list,
189 .It USERSUSPENDREQ
190 should include sync in the command list,
191 .It BATTERYLOW
192 only zzz should be specified in the command list.
193 .El
194 .It
195 - Events passed to
196 .Nm
197 after kernel handling:
198 .Pp
199 .Bl -tag -width USERSUSPENDREQ -compact -offset indent
200 .It NORMRESUME
201 .It CRITRESUME
202 .It STANDBYRESUME
203 .It POWERSTATECHANGE
204 .It UPDATETIME
205 .It CAPABILITIESCHANGE
206 .El
207 .Pp
208 Other events will not be sent to
209 .Nm .
210 .El
211 .Ed
212 .It
213 command line syntax
214 .Bd -ragged -offset indent
215 In the example above, the three lines beginning with
216 .Ql exec
217 are commands for the event.
218 Each line should be terminated with a semicolon.
219 The command list for the event should be enclosed by
220 .Ql {
221 and
222 .Ql } .
223 The
224 .Nm
225 utility uses
226 .Pa /bin/sh
227 for double-quotation enclosed command execution, just as with
228 .Xr system 3 .
229 Each command is executed in order until the end of
230 the list is reached or a command finishes with a non-zero status code.
231 The
232 .Nm
233 utility will report any failed command's status code via
234 .Xr syslog 3
235 and will then reject the request event posted by the APM BIOS.
236 .Ed
237 .It
238 Built-in functions
239 .Bd -ragged -offset indent
240 You can also specify
241 .Nm
242 built-in functions instead of command lines.
243 A built-in function name should be terminated with a semicolon,
244 just as with a command line.
245 The following built-in functions are currently supported:
246 .Bl -item
247 .It
248 .Bl -tag -width ".It - reject"
249 .It - reject
250 Reject last request posted by APM BIOS.
251 This can be used to reject
252 a SUSPEND request when the LCD is closed and put the system in a
253 STANDBY state instead.
254 .El
255 .El
256 .Ed
257 .El
258 .Sh FILES
259 .Bl -tag -width /etc/apmd.conf -compact
260 .It Pa /etc/apmd.conf
261 .It Pa /dev/apmctl
262 .It Pa /var/run/apmd.pid
263 .El
264 .Sh EXAMPLES
265 Sample configuration commands include:
266 .Bd -literal
267 apm_event SUSPENDREQ {
268         exec "/etc/rc.suspend apm suspend";
269 }
270
271 apm_event USERSUSPENDREQ {
272         exec "sync && sync && sync";
273         exec "sleep 1";
274         exec "apm -z";
275 }
276
277 apm_event NORMRESUME {
278         exec "/etc/rc.resume apm suspend";
279 }
280
281 apm_event STANDBYRESUME {
282         exec "/etc/rc.resume apm standby";
283 }
284
285 # resume event configuration for serial mouse users by
286 # reinitializing a moused(8) connected to a serial port.
287 #
288 #apm_event NORMRESUME {
289 #       exec "kill -HUP `cat /var/run/moused.pid`";
290 #}
291 #
292 # suspend request event configuration for ATA HDD users:
293 # execute standby instead of suspend.
294 #
295 #apm_event SUSPENDREQ {
296 #       reject;
297 #       exec "sync && sync && sync";
298 #       exec "sleep 1";
299 #       exec "apm -Z";
300 #}
301 .Ed
302 .Sh SEE ALSO
303 .Xr apm 4 ,
304 .Xr apm 8
305 .Sh HISTORY
306 The
307 .Nm
308 utility appeared in
309 .Fx 3.3 .
310 .Sh AUTHORS
311 .An Mitsuru IWASAKI Aq iwasaki@FreeBSD.org
312 .An KOIE Hidetaka Aq koie@suri.co.jp
313 .Pp
314 .An -nosplit
315 Some contributions made by
316 .An Warner Losh Aq imp@FreeBSD.org ,
317 .An Hiroshi Yamashita Aq bluemoon@msj.biglobe.ne.jp ,
318 .An Yoshihiko SARUMARU Aq mistral@imasy.or.jp ,
319 .An Norihiro Kumagai Aq kuma@nk.rim.or.jp ,
320 .An NAKAGAWA Yoshihisa Aq nakagawa@jp.FreeBSD.org ,
321 and
322 .An Nick Hilliard Aq nick@foobar.org .