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