1.\" $NetBSD: powerd.8,v 1.17 2007/10/10 23:46:01 xtraeme 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 October 11, 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.El 114.Pp 115The following events are defined for power switch devices: 116.Bl -tag -width "released" 117.It pressed 118The button was pressed, the lid closed, or the AC adapter connected. 119.It released 120The button was released, the lid opened, or the AC adapter disconnected. 121Note that power and sleep button devices usually do not 122post this type of event. 123.El 124.Pp 125The following is an example of how a power button script might be invoked 126when a power button is pressed by the operator: 127.Bd -literal -offset indent 128/etc/powerd/scripts/power_button acpi0 pressed 129.Ed 130.Ss ENVSYS SCRIPTS 131.Xr envsys 4 132scripts are called when a condition was triggered in a sensor. 133These scripts are called with three arguments: the 134device associated, the event type and sensor's name. 135The 136.Sy sensor_drive 137and the 138.Sy sensor_battery 139scripts uses a fourth argument: state description. 140.Pp 141The following envsys script names are defined: 142.Bl -tag -width "sensor_temperature" 143.It sensor_battery 144This script is called when an event occurs on a battery sensor 145(Wh/Ah/Battery state). 146.It sensor_drive 147This script is called when an event occurs on a drive sensor. 148.It sensor_fan 149This script is called when an event occurs on a fan sensor. 150.It sensor_indicator 151This script is called when an event ocurrs on a indicator/integer sensor. 152.It sensor_power 153This script is called when an event occurs on a power sensor (W/Ampere). 154.It sensor_resistance 155This script is called when an event occurs on a resistance sensor (Ohm). 156.It sensor_temperature 157This script is called when an event occurs on a temperature sensor. 158.It sensor_voltage 159This script is called when an event occurs on a voltage sensor. 160.El 161.Pp 162The following event is defined for all scripts but is only sent if 163a critical/warning or any other event was previously sent: 164.Bl -tag -width "sensor_temperature" 165.It normal 166A normal state/capacity/condition was triggered. 167.El 168.Pp 169The following events are defined for fan, indicator, power, 170resistance, temperature and voltage sensors: 171.Bl -tag -width "sensor_temperature" 172.It critical 173A critical condition was triggered. 174.It critical-under 175A critical under condition was triggered. 176.It critical-over 177A critical over condition was triggered. 178.It warning-under 179A warning under condition was triggered. 180.It warning-over 181A warning over condition was triggered. 182.El 183.Pp 184The following events are defined only for battery sensors: 185.Bl -tag -width "sensor_temperature" 186.It user-capacity 187Capacity dropped below the limit set by the user. 188.It low-power 189System is running in low power, that means that there is not 190any AC Adapter connected and all batteries are in critical or 191low capacity. When this event is received there's no much time 192so you should only suspend or shutdown the system. The script 193shutdowns the system gracefully by default. 194.El 195.Pp 196The following events are defined for drive and battery sensors: 197.Bl -tag -width "sensor_temperature" 198.It state-changed 199The state on the sensor has been changed and it's not in normal state. 200.El 201.Pp 202The following is an example of how a temperature sensor script might be 203invoked when a critical over condition is triggered: 204.Bd -literal -offset indent 205/etc/powerd/scripts/sensor_temperature lm0 critical-over "CPU Temp" 206.Ed 207.Sh SEE ALSO 208.Xr acpi 4 , 209.Xr acpiacad 4 , 210.Xr acpibut 4 , 211.Xr acpilid 4 , 212.Xr envsys 4 , 213.Xr i386/apm 4 214.Sh HISTORY 215.Nm 216first appeared in 217.Nx 2.0 . 218Support to handle 219.Xr envsys 4 220events appeared in 221.Nx 5.0 . 222.Sh AUTHORS 223.Nm 224was written by 225.An Jason R. Thorpe 226.Aq thorpej@wasabisystems.com 227and contributed by Wasabi Systems, Inc. 228.An Juan Romero Pardines 229added support to handle 230.Xr envsys 4 231events. 232.Sh BUGS 233Due to its synchronous nature 234.Nm 235cannot be trusted to handle events within a certain time. 236