1.\" $NetBSD: sysmon_pswitch.9,v 1.3 2010/01/29 11:24:31 jruoho Exp $ 2.\" 3.\" Copyright (c) 2010 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Jukka Ruohonen. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd January 26, 2010 31.Dt SYSMON_PSWITCH 9 32.Os 33.Sh NAME 34.Nm sysmon_pswitch 35.Nd framework for power switches 36.Sh SYNOPSIS 37.In dev/sysmon/sysmonvar.h 38.Ft int 39.Fn sysmon_pswitch_register "struct sysmon_pswitch *smpsw" 40.Ft void 41.Fn sysmon_pswitch_unregister "struct sysmon_pswitch *smpsw" 42.Ft void 43.Fn sysmon_pswitch_event "struct sysmon_pswitch *smpsw" "int event" 44.Sh DESCRIPTION 45The machine-independent 46.Nm 47provides a framework for power management. 48The interface has been largely superceded by the 49.Xr pmf 9 50framework, but 51.Nm 52is still used to manage power switches as well as 53related mechanical adapters and buttons. 54These are encapsulated in the following structure: 55.Bd -literal 56struct sysmon_pswitch { 57 const char *smpsw_name; /* power switch name */ 58 int smpsw_type; /* power switch type */ 59 60 LIST_ENTRY(sysmon_pswitch) smpsw_list; 61}; 62.Ed 63.Pp 64Unsurprisingly, 65.Fa smpsw_name 66specifies the name of the power switch and 67.Fa smpsw_type 68defines the type of it. 69The following types are defined: 70.Pp 71.Bl -tag -width PSWITCH_HK_VENDOR_BUTTON -compact -offset indent 72.It PSWITCH_TYPE_POWER 73.It PSWITCH_TYPE_SLEEP 74.It PSWITCH_TYPE_LID 75.It PSWITCH_TYPE_RESET 76.It PSWITCH_TYPE_ACADAPTER 77.It PSWITCH_TYPE_HOTKEY 78.El 79.Pp 80If the type is 81.Dv PSWITCH_TYPE_HOTKEY , 82there are few predefined names that can be used for 83.Fa smpsw_name : 84.Pp 85.Bl -tag -width PSWITCH_HK_VENDOR_BUTTON -compact -offset indent 86.It PSWITCH_HK_DISPLAY_CYCLE 87.Em display-cycle 88.It PSWITCH_HK_LOCK_SCREEN 89.Em lock-screen 90.It PSWITCH_HK_BATTERY_INFO 91.Em battery-info 92.It PSWITCH_HK_EJECT_BUTTON 93.Em eject-button 94.It PSWITCH_HK_ZOOM_BUTTON 95.Em zoom-button 96.It PSWITCH_HK_VENDOR_BUTTON 97.Em vendor-button 98.El 99.Pp 100Once a power switch event has been proceeded, 101.Nm 102will inform the user space 103.Xr powerd 8 , 104which will possibly execute a script matching the type of the power switch. 105.Sh FUNCTIONS 106After the 107.Em sysmon_pswitch 108structure has been initialized, 109a new power switch device can be registered by using 110.Fn sysmon_pswitch_register . 111The device can be detached from the framework by 112.Fn sysmon_pswitch_unregister . 113.Pp 114The 115.Fn sysmon_pswitch_event 116is used to signal a new power switch event. 117There are two possibilities for the value of 118.Fa event : 119.Bl -tag -width PSWITCH_HK_VENDOR_BUTTON -offset indent 120.It PSWITCH_EVENT_PRESSED 121A button has been pressed, the lid has been closed, the AC adapter is off, etc. 122.It PSWITCH_EVENT_RELEASED 123A button has been released, the lid is open, the AC adapter is on, etc. 124.El 125.Pp 126The corresponding events in 127.Xr powerd 8 128are 129.Em pressed 130and 131.Em released . 132.Sh SEE ALSO 133.Xr powerd 8 , 134.Xr pmf 9 , 135.Xr sysmon_envsys 9 , 136.Xr sysmon_taskq 9 137.Sh AUTHORS 138.An Jason R. Thorpe Aq thorpej@NetBSD.org 139