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