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