xref: /netbsd-src/usr.sbin/powerd/powerd.8 (revision 7f21db1c0118155e0dd40b75182e30c589d9f63e)
1.\"	$NetBSD: powerd.8,v 1.22 2010/01/27 06:52:24 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 January 26, 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 d
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 will be sent to stderr and
62.Nm
63will stay in the foreground of the controlling terminal.
64.El
65.Sh CONFIGURATION SCRIPTS
66All configuration of
67.Nm
68is encapsulated into scripts that are run when power management events occur.
69The daemon will look for the scripts from the directory
70.Pa /etc/powerd/scripts .
71.Pp
72Configuration scripts are run synchronously;
73.Nm
74will start the script and wait for its completion before it handles
75the next event.
76.Pp
77Configuration scripts are called with different arguments, depending on
78the script class.
79These classes are described in the following sections.
80.Ss POWER SWITCH SCRIPTS
81Power switch scripts are called when a state change event occurs on
82a power switch device.
83Power switch scripts are called with two arguments: the device with which
84the event is associated, and the event type.
85.Pp
86The following power switch script names are defined:
87.Bl -tag -width "hotkey_button"
88.It Em power_button
89This script is called when an event occurs on a power button device.
90.It Em reset_button
91This script is called when an event occurs on a reset button device.
92.It Em sleep_button
93This script is called when an event occurs on a sleep button device.
94.It Em lid_switch
95This script is called when an event occurs on a lid switch device.
96.It Em acadapter
97This script is called when an online or offline event occurs on an
98AC adapter device.
99.It Em hotkey_button
100This script is called when an event occurs on a hotkey button device.
101.El
102.Pp
103The following events are defined for power switch devices:
104.Bl -tag -width "hotkey_button"
105.It Em pressed
106The button was pressed, the lid was closed,
107or the AC adapter was connected.
108.It Em released
109The button was released, the lid was opened,
110or the AC adapter was disconnected.
111Note that power and sleep button devices usually do not
112post this type of event.
113.El
114.Pp
115The following is an example of how a power button script might be invoked
116when a power button is pressed by the operator:
117.Bd -literal -offset indent
118/etc/powerd/scripts/power_button acpibut0 pressed
119.Ed
120.Ss ENVSYS SCRIPTS
121.Xr envsys 4
122scripts are called when a condition was triggered in a sensor.
123These scripts are called with three arguments: the
124device associated, the event type, and the sensor's name.
125The
126.Sy sensor_drive
127and the
128.Sy sensor_battery
129scripts uses a fourth argument: state description.
130.Pp
131The following envsys script names are defined:
132.Bl -tag -width "sensor_temperature"
133.It Em sensor_battery
134This script is called when an event occurs on a battery sensor
135(Wh/Ah/Battery state).
136.It Em sensor_drive
137This script is called when an event occurs on a drive sensor.
138.It Em sensor_fan
139This script is called when an event occurs on a fan sensor.
140.It Em sensor_indicator
141This script is called when an event ocurrs on a indicator/integer sensor.
142.It Em sensor_power
143This script is called when an event occurs on a power sensor (W/Ampere).
144.It Em sensor_resistance
145This script is called when an event occurs on a resistance sensor (Ohm).
146.It Em sensor_temperature
147This script is called when an event occurs on a temperature sensor.
148.It Em sensor_voltage
149This script is called when an event occurs on a voltage sensor.
150.El
151.Pp
152The following events are defined for fan, indicator, power,
153resistance, temperature, and voltage sensors:
154.Bl -tag -width "sensor_temperature"
155.It Em critical
156A critical condition was triggered.
157.It Em critical-under
158A critical under condition was triggered.
159.It Em critical-over
160A critical over condition was triggered.
161.It Em warning-under
162A warning under condition was triggered.
163.It Em warning-over
164A warning over condition was triggered.
165.El
166.Pp
167The following event is defined for all scripts, but it is only sent if
168any of the previous events has been previously sent:
169.Bl -tag -width "sensor_temperature"
170.It Em normal
171A normal state/capacity/condition was triggered.
172.El
173.Pp
174The following events are defined only for battery sensors:
175.Bl -tag -width "sensor_temperature"
176.It Em user-capacity
177Capacity dropped below the limit set by the user.
178.It Em low-power
179System is running in low power.
180This implies that the AC adapter is disconnected and
181all batteries are in critical or low capacity.
182The script shutdowns the system gracefully by default.
183.El
184.Pp
185The following events are defined for drive and battery sensors:
186.Bl -tag -width "sensor_temperature"
187.It Em state-changed
188The state of the sensor has been changed and it is not in the normal state.
189.El
190.Pp
191The following is an example of how a temperature sensor script might be
192invoked when a critical over condition is triggered:
193.Bd -literal -offset indent
194/etc/powerd/scripts/sensor_temperature lm0 critical-over "CPU Temp"
195.Ed
196.Sh SEE ALSO
197.Xr acpi 4 ,
198.Xr acpiacad 4 ,
199.Xr acpibut 4 ,
200.Xr acpilid 4 ,
201.Xr envsys 4 ,
202.Xr i386/apm 4
203.Sh HISTORY
204.Nm
205first appeared in
206.Nx 2.0 .
207Support to handle
208.Xr envsys 4
209events appeared in
210.Nx 5.0 .
211.Sh AUTHORS
212.Nm
213was written by
214.An Jason R. Thorpe
215.Aq thorpej@wasabisystems.com
216and contributed by Wasabi Systems, Inc.
217.An Juan Romero Pardines
218added support to handle
219.Xr envsys 4
220events.
221.Sh BUGS
222Due to its synchronous nature
223.Nm
224cannot be trusted to handle events within a certain time.
225