xref: /netbsd-src/usr.sbin/powerd/powerd.8 (revision daf6c4152fcddc27c445489775ed1f66ab4ea9a9)
1.\"	$NetBSD: powerd.8,v 1.24 2010/12/15 18:11:01 wiz Exp $
2.\"
3.\" Copyright (c) 2003 Wasabi Systems, Inc.
4.\" All rights reserved.
5.\"
6.\" Written by Jason R. Thorpe for Wasabi Systems, Inc.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\" 3. All advertising materials mentioning features or use of this software
17.\"    must display the following acknowledgement:
18.\"	This product includes software developed for the NetBSD Project by
19.\"	Wasabi Systems, Inc.
20.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse
21.\"    or promote products derived from this software without specific prior
22.\"    written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
28.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34.\" POSSIBILITY OF SUCH DAMAGE.
35.\"
36.Dd December 15, 2010
37.Dt POWERD 8
38.Os
39.Sh NAME
40.Nm powerd
41.Nd power management daemon for sysmon
42.Sh SYNOPSIS
43.Nm
44.Op Fl dn
45.Sh DESCRIPTION
46.Nm
47acts upon power management events posted by the kernel's power management
48facility.
49When events are posted,
50.Nm
51translates the event into a script name and a list of arguments.
52.Nm
53then runs the script in order to implement the power management policy
54defined by the system administrator.
55.Pp
56.Nm
57supports the following option:
58.Bl -tag -width xxxx
59.It Fl d
60Enable debugging mode.
61Verbose messages and all messages intended for
62.Xr syslog 8
63will be sent to stderr, and
64.Nm
65will stay in the foreground of the controlling terminal.
66.It Fl n
67Prevent execution of power management scripts.
68.El
69.Sh CONFIGURATION SCRIPTS
70All configuration of
71.Nm
72is encapsulated into scripts that are run when power management events occur.
73The daemon will look for the scripts from the directory
74.Pa /etc/powerd/scripts .
75.Pp
76Configuration scripts are run synchronously;
77.Nm
78will start the script and wait for its completion before it handles
79the next event.
80.Pp
81Configuration scripts are called with different arguments, depending on
82the script class.
83These classes are described in the following sections.
84.Ss POWER SWITCH SCRIPTS
85Power switch scripts are called when a state change event occurs on
86a power switch device.
87Power switch scripts are called with two arguments: the device with which
88the event is associated, and the event type.
89.Pp
90The following power switch script names are defined:
91.Bl -tag -width "hotkey_button"
92.It Em power_button
93This script is called when an event occurs on a power button device.
94.It Em reset_button
95This script is called when an event occurs on a reset button device.
96.It Em sleep_button
97This script is called when an event occurs on a sleep button device.
98.It Em lid_switch
99This script is called when an event occurs on a lid switch device.
100.It Em acadapter
101This script is called when an online or offline event occurs on an
102AC adapter device.
103.It Em hotkey_button
104This script is called when an event occurs on a hotkey button device.
105.El
106.Pp
107The following events are defined for power switch devices:
108.Bl -tag -width "hotkey_button"
109.It Em pressed
110The button was pressed, the lid was closed,
111or the AC adapter was connected.
112.It Em released
113The button was released, the lid was opened,
114or the AC adapter was disconnected.
115Note that power and sleep button devices usually do not
116post this type of event.
117.El
118.Pp
119The following is an example of how a power button script might be invoked
120when a power button is pressed by the operator:
121.Bd -literal -offset indent
122/etc/powerd/scripts/power_button acpibut0 pressed
123.Ed
124.Ss ENVSYS SCRIPTS
125.Xr envsys 4
126scripts are called when a condition was triggered in a sensor.
127These scripts are called with three arguments: the
128device associated, the event type, and the sensor's name.
129The
130.Sy sensor_drive
131and the
132.Sy sensor_battery
133scripts uses a fourth argument: state description.
134.Pp
135The following envsys script names are defined:
136.Bl -tag -width "sensor_temperature"
137.It Em sensor_battery
138This script is called when an event occurs on a battery sensor
139(Wh/Ah/Battery state).
140.It Em sensor_drive
141This script is called when an event occurs on a drive sensor.
142.It Em sensor_fan
143This script is called when an event occurs on a fan sensor.
144.It Em sensor_indicator
145This script is called when an event ocurrs on a indicator/integer sensor.
146.It Em sensor_power
147This script is called when an event occurs on a power sensor (W/Ampere).
148.It Em sensor_resistance
149This script is called when an event occurs on a resistance sensor (Ohm).
150.It Em sensor_temperature
151This script is called when an event occurs on a temperature sensor.
152.It Em sensor_voltage
153This script is called when an event occurs on a voltage sensor.
154.El
155.Pp
156The following events are defined for fan, indicator, power,
157resistance, temperature, and voltage sensors:
158.Bl -tag -width "sensor_temperature"
159.It Em critical
160A critical condition was triggered.
161.It Em critical-under
162A critical under condition was triggered.
163.It Em critical-over
164A critical over condition was triggered.
165.It Em warning-under
166A warning under condition was triggered.
167.It Em warning-over
168A warning over condition was triggered.
169.El
170.Pp
171The following event is defined for all scripts, but it is only sent if
172any of the previous events has been previously sent:
173.Bl -tag -width "sensor_temperature"
174.It Em normal
175A normal state/capacity/condition was triggered.
176.El
177.Pp
178The following events are defined only for battery sensors:
179.Bl -tag -width "sensor_temperature"
180.It Em user-capacity
181Capacity dropped below the limit set by the user.
182.It Em low-power
183System is running in low power.
184This implies that the AC adapter is disconnected and
185all batteries are in critical or low capacity.
186The script shutdowns the system gracefully by default.
187.El
188.Pp
189The following events are defined for drive and battery sensors:
190.Bl -tag -width "sensor_temperature"
191.It Em state-changed
192The state of the sensor has been changed and it is not in the normal state.
193.El
194.Pp
195The following is an example of how a temperature sensor script might be
196invoked when a critical over condition is triggered:
197.Bd -literal -offset indent
198/etc/powerd/scripts/sensor_temperature lm0 critical-over "CPU Temp"
199.Ed
200.Sh SEE ALSO
201.Xr acpi 4 ,
202.Xr acpiacad 4 ,
203.Xr acpibut 4 ,
204.Xr acpilid 4 ,
205.Xr envsys 4 ,
206.Xr i386/apm 4
207.Sh HISTORY
208.Nm
209first appeared in
210.Nx 2.0 .
211Support to handle
212.Xr envsys 4
213events appeared in
214.Nx 5.0 .
215.Sh AUTHORS
216.Nm
217was written by
218.An Jason R. Thorpe
219.Aq thorpej@wasabisystems.com
220and contributed by Wasabi Systems, Inc.
221.An Juan Romero Pardines
222added support to handle
223.Xr envsys 4
224events.
225.Sh BUGS
226Due to its synchronous nature
227.Nm
228cannot be trusted to handle events within a certain time.
229