1*7197d240Sabhinav.\" $NetBSD: powerd.8,v 1.26 2017/02/21 15:15:19 abhinav Exp $ 2539625c0Sthorpej.\" 3539625c0Sthorpej.\" Copyright (c) 2003 Wasabi Systems, Inc. 4539625c0Sthorpej.\" All rights reserved. 5539625c0Sthorpej.\" 6539625c0Sthorpej.\" Written by Jason R. Thorpe for Wasabi Systems, Inc. 7539625c0Sthorpej.\" 8539625c0Sthorpej.\" Redistribution and use in source and binary forms, with or without 9539625c0Sthorpej.\" modification, are permitted provided that the following conditions 10539625c0Sthorpej.\" are met: 11539625c0Sthorpej.\" 1. Redistributions of source code must retain the above copyright 12539625c0Sthorpej.\" notice, this list of conditions and the following disclaimer. 13539625c0Sthorpej.\" 2. Redistributions in binary form must reproduce the above copyright 14539625c0Sthorpej.\" notice, this list of conditions and the following disclaimer in the 15539625c0Sthorpej.\" documentation and/or other materials provided with the distribution. 16539625c0Sthorpej.\" 3. All advertising materials mentioning features or use of this software 17539625c0Sthorpej.\" must display the following acknowledgement: 18539625c0Sthorpej.\" This product includes software developed for the NetBSD Project by 19539625c0Sthorpej.\" Wasabi Systems, Inc. 20539625c0Sthorpej.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse 21539625c0Sthorpej.\" or promote products derived from this software without specific prior 22539625c0Sthorpej.\" written permission. 23539625c0Sthorpej.\" 24539625c0Sthorpej.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 25539625c0Sthorpej.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26539625c0Sthorpej.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27539625c0Sthorpej.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 28539625c0Sthorpej.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29539625c0Sthorpej.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30539625c0Sthorpej.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31539625c0Sthorpej.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32539625c0Sthorpej.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33539625c0Sthorpej.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34539625c0Sthorpej.\" POSSIBILITY OF SUCH DAMAGE. 35539625c0Sthorpej.\" 365702902fSpgoyette.Dd December 15, 2010 37539625c0Sthorpej.Dt POWERD 8 38539625c0Sthorpej.Os 39539625c0Sthorpej.Sh NAME 40539625c0Sthorpej.Nm powerd 41539625c0Sthorpej.Nd power management daemon for sysmon 42539625c0Sthorpej.Sh SYNOPSIS 43539625c0Sthorpej.Nm 448d07e89eSwiz.Op Fl dn 45539625c0Sthorpej.Sh DESCRIPTION 46539625c0Sthorpej.Nm 47539625c0Sthorpejacts upon power management events posted by the kernel's power management 48539625c0Sthorpejfacility. 49539625c0SthorpejWhen events are posted, 50539625c0Sthorpej.Nm 51539625c0Sthorpejtranslates the event into a script name and a list of arguments. 52539625c0Sthorpej.Nm 53539625c0Sthorpejthen runs the script in order to implement the power management policy 54539625c0Sthorpejdefined by the system administrator. 55539625c0Sthorpej.Pp 56cbb9c721SdhollandThe following options are available: 57539625c0Sthorpej.Bl -tag -width xxxx 58539625c0Sthorpej.It Fl d 59170f2084SwizEnable debugging mode. 605702902fSpgoyetteVerbose messages and all messages intended for 615702902fSpgoyette.Xr syslog 8 625702902fSpgoyettewill be sent to stderr, and 63539625c0Sthorpej.Nm 64539625c0Sthorpejwill stay in the foreground of the controlling terminal. 655702902fSpgoyette.It Fl n 665702902fSpgoyettePrevent execution of power management scripts. 67539625c0Sthorpej.El 68539625c0Sthorpej.Sh CONFIGURATION SCRIPTS 69df40d4f1SjruohoAll configuration of 70af211bb4Sxtraeme.Nm 71df40d4f1Sjruohois encapsulated into scripts that are run when power management events occur. 72df40d4f1SjruohoThe daemon will look for the scripts from the directory 73539625c0Sthorpej.Pa /etc/powerd/scripts . 74539625c0Sthorpej.Pp 75df40d4f1SjruohoConfiguration scripts are run synchronously; 767064ed78Saugustss.Nm 777064ed78Saugustsswill start the script and wait for its completion before it handles 787064ed78Saugustssthe next event. 797064ed78Saugustss.Pp 80539625c0SthorpejConfiguration scripts are called with different arguments, depending on 81170f2084Swizthe script class. 82170f2084SwizThese classes are described in the following sections. 83539625c0Sthorpej.Ss POWER SWITCH SCRIPTS 84539625c0SthorpejPower switch scripts are called when a state change event occurs on 85539625c0Sthorpeja power switch device. 86539625c0SthorpejPower switch scripts are called with two arguments: the device with which 87df40d4f1Sjruohothe event is associated, and the event type. 88539625c0Sthorpej.Pp 89539625c0SthorpejThe following power switch script names are defined: 9065a2d62aSjruoho.Bl -tag -width "hotkey_button" 9165a2d62aSjruoho.It Em power_button 92539625c0SthorpejThis script is called when an event occurs on a power button device. 9365a2d62aSjruoho.It Em reset_button 94e6227d3cSthorpejThis script is called when an event occurs on a reset button device. 9565a2d62aSjruoho.It Em sleep_button 96539625c0SthorpejThis script is called when an event occurs on a sleep button device. 9765a2d62aSjruoho.It Em lid_switch 98539625c0SthorpejThis script is called when an event occurs on a lid switch device. 9965a2d62aSjruoho.It Em acadapter 100af211bb4SxtraemeThis script is called when an online or offline event occurs on an 101af211bb4SxtraemeAC adapter device. 10265a2d62aSjruoho.It Em hotkey_button 103941ceb87SjmcneillThis script is called when an event occurs on a hotkey button device. 104539625c0Sthorpej.El 105539625c0Sthorpej.Pp 106539625c0SthorpejThe following events are defined for power switch devices: 10765a2d62aSjruoho.Bl -tag -width "hotkey_button" 10865a2d62aSjruoho.It Em pressed 109df40d4f1SjruohoThe button was pressed, the lid was closed, 110df40d4f1Sjruohoor the AC adapter was connected. 11165a2d62aSjruoho.It Em released 112df40d4f1SjruohoThe button was released, the lid was opened, 113df40d4f1Sjruohoor the AC adapter was disconnected. 114539625c0SthorpejNote that power and sleep button devices usually do not 115539625c0Sthorpejpost this type of event. 116539625c0Sthorpej.El 117539625c0Sthorpej.Pp 118539625c0SthorpejThe following is an example of how a power button script might be invoked 119539625c0Sthorpejwhen a power button is pressed by the operator: 120539625c0Sthorpej.Bd -literal -offset indent 121df40d4f1Sjruoho/etc/powerd/scripts/power_button acpibut0 pressed 122539625c0Sthorpej.Ed 123af211bb4Sxtraeme.Ss ENVSYS SCRIPTS 124af211bb4Sxtraeme.Xr envsys 4 1256263ca5fSxtraemescripts are called when a condition was triggered in a sensor. 126af211bb4SxtraemeThese scripts are called with three arguments: the 127df40d4f1Sjruohodevice associated, the event type, and the sensor's name. 128af211bb4SxtraemeThe 129af211bb4Sxtraeme.Sy sensor_drive 1306263ca5fSxtraemeand the 1316263ca5fSxtraeme.Sy sensor_battery 1326263ca5fSxtraemescripts uses a fourth argument: state description. 133af211bb4Sxtraeme.Pp 134af211bb4SxtraemeThe following envsys script names are defined: 135af211bb4Sxtraeme.Bl -tag -width "sensor_temperature" 13665a2d62aSjruoho.It Em sensor_battery 1376263ca5fSxtraemeThis script is called when an event occurs on a battery sensor 1386263ca5fSxtraeme(Wh/Ah/Battery state). 13965a2d62aSjruoho.It Em sensor_drive 140af211bb4SxtraemeThis script is called when an event occurs on a drive sensor. 14165a2d62aSjruoho.It Em sensor_fan 142af211bb4SxtraemeThis script is called when an event occurs on a fan sensor. 14365a2d62aSjruoho.It Em sensor_indicator 144*7197d240SabhinavThis script is called when an event occurs on a indicator/integer sensor. 14565a2d62aSjruoho.It Em sensor_power 146af211bb4SxtraemeThis script is called when an event occurs on a power sensor (W/Ampere). 14765a2d62aSjruoho.It Em sensor_resistance 148af211bb4SxtraemeThis script is called when an event occurs on a resistance sensor (Ohm). 14965a2d62aSjruoho.It Em sensor_temperature 150af211bb4SxtraemeThis script is called when an event occurs on a temperature sensor. 15165a2d62aSjruoho.It Em sensor_voltage 152af211bb4SxtraemeThis script is called when an event occurs on a voltage sensor. 153af211bb4Sxtraeme.El 154af211bb4Sxtraeme.Pp 155019fd89dSxtraemeThe following events are defined for fan, indicator, power, 156df40d4f1Sjruohoresistance, temperature, and voltage sensors: 157af211bb4Sxtraeme.Bl -tag -width "sensor_temperature" 15865a2d62aSjruoho.It Em critical 159af211bb4SxtraemeA critical condition was triggered. 16065a2d62aSjruoho.It Em critical-under 161af211bb4SxtraemeA critical under condition was triggered. 16265a2d62aSjruoho.It Em critical-over 163af211bb4SxtraemeA critical over condition was triggered. 16465a2d62aSjruoho.It Em warning-under 165af211bb4SxtraemeA warning under condition was triggered. 16665a2d62aSjruoho.It Em warning-over 167af211bb4SxtraemeA warning over condition was triggered. 168af211bb4Sxtraeme.El 169af211bb4Sxtraeme.Pp 170df40d4f1SjruohoThe following event is defined for all scripts, but it is only sent if 171df40d4f1Sjruohoany of the previous events has been previously sent: 172df40d4f1Sjruoho.Bl -tag -width "sensor_temperature" 173df40d4f1Sjruoho.It Em normal 174df40d4f1SjruohoA normal state/capacity/condition was triggered. 175df40d4f1Sjruoho.El 176df40d4f1Sjruoho.Pp 177a1def00dSxtraemeThe following events are defined only for battery sensors: 178af211bb4Sxtraeme.Bl -tag -width "sensor_temperature" 17965a2d62aSjruoho.It Em user-capacity 1806263ca5fSxtraemeCapacity dropped below the limit set by the user. 18165a2d62aSjruoho.It Em low-power 182df40d4f1SjruohoSystem is running in low power. 183df40d4f1SjruohoThis implies that the AC adapter is disconnected and 184df40d4f1Sjruohoall batteries are in critical or low capacity. 185274aaf51SwizThe script shutdowns the system gracefully by default. 186af211bb4Sxtraeme.El 187af211bb4Sxtraeme.Pp 1886263ca5fSxtraemeThe following events are defined for drive and battery sensors: 189af211bb4Sxtraeme.Bl -tag -width "sensor_temperature" 19065a2d62aSjruoho.It Em state-changed 191df40d4f1SjruohoThe state of the sensor has been changed and it is not in the normal state. 192af211bb4Sxtraeme.El 193af211bb4Sxtraeme.Pp 194af211bb4SxtraemeThe following is an example of how a temperature sensor script might be 195af211bb4Sxtraemeinvoked when a critical over condition is triggered: 196af211bb4Sxtraeme.Bd -literal -offset indent 197af211bb4Sxtraeme/etc/powerd/scripts/sensor_temperature lm0 critical-over "CPU Temp" 198af211bb4Sxtraeme.Ed 199539625c0Sthorpej.Sh SEE ALSO 200539625c0Sthorpej.Xr acpi 4 , 20178ac4f02Skochi.Xr acpiacad 4 , 202ffaf7e29Skochi.Xr acpibut 4 , 203ffaf7e29Skochi.Xr acpilid 4 , 204af211bb4Sxtraeme.Xr envsys 4 , 205af211bb4Sxtraeme.Xr i386/apm 4 206539625c0Sthorpej.Sh HISTORY 207539625c0Sthorpej.Nm 208539625c0Sthorpejfirst appeared in 209539625c0Sthorpej.Nx 2.0 . 210af211bb4SxtraemeSupport to handle 211af211bb4Sxtraeme.Xr envsys 4 212af211bb4Sxtraemeevents appeared in 213af211bb4Sxtraeme.Nx 5.0 . 214539625c0Sthorpej.Sh AUTHORS 215539625c0Sthorpej.Nm 216539625c0Sthorpejwas written by 217539625c0Sthorpej.An Jason R. Thorpe 218539625c0Sthorpej.Aq thorpej@wasabisystems.com 219539625c0Sthorpejand contributed by Wasabi Systems, Inc. 2205779f29aSxtraeme.An Juan Romero Pardines 2215779f29aSxtraemeadded support to handle 2225779f29aSxtraeme.Xr envsys 4 2235779f29aSxtraemeevents. 224b461e245Swiz.Sh BUGS 225b461e245SwizDue to its synchronous nature 226b461e245Swiz.Nm 227b461e245Swizcannot be trusted to handle events within a certain time. 228