xref: /netbsd-src/share/man/man9/sysmon_pswitch.9 (revision d06f29fd8aa3f78273982e4db53d97e1e14bf5b6)
1.\" $NetBSD: sysmon_pswitch.9,v 1.7 2016/06/01 02:06:54 pgoyette 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 6, 2015
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 superseded 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.It PSWITCH_TYPE_RADIO
79.El
80.Pp
81If the type is
82.Dv PSWITCH_TYPE_HOTKEY ,
83there are few predefined names that can be used for
84.Fa smpsw_name :
85.Pp
86.Bl -tag -width PSWITCH_HK_VENDOR_BUTTON -compact -offset indent
87.It PSWITCH_HK_DISPLAY_CYCLE
88.Em display-cycle
89.It PSWITCH_HK_LOCK_SCREEN
90.Em lock-screen
91.It PSWITCH_HK_BATTERY_INFO
92.Em battery-info
93.It PSWITCH_HK_EJECT_BUTTON
94.Em eject-button
95.It PSWITCH_HK_ZOOM_BUTTON
96.Em zoom-button
97.It PSWITCH_HK_VENDOR_BUTTON
98.Em vendor-button
99.El
100.Pp
101Once a power switch event has been proceeded,
102.Nm
103will inform the user space
104.Xr powerd 8 ,
105which will possibly execute a script matching the type of the power switch.
106.Sh FUNCTIONS
107After the
108.Em sysmon_pswitch
109structure has been initialized,
110a new power switch device can be registered by using
111.Fn sysmon_pswitch_register .
112The device can be detached from the framework by
113.Fn sysmon_pswitch_unregister .
114.Pp
115The
116.Fn sysmon_pswitch_event
117is used to signal a new power switch event.
118There are two possibilities for the value of
119.Fa event :
120.Bl -tag -width PSWITCH_HK_VENDOR_BUTTON -offset indent
121.It PSWITCH_EVENT_PRESSED
122A button has been pressed, the lid has been closed, the AC adapter is off, etc.
123.It PSWITCH_EVENT_RELEASED
124A button has been released, the lid is open, the AC adapter is on, etc.
125.El
126.Pp
127The corresponding events in
128.Xr powerd 8
129are
130.Em pressed
131and
132.Em released .
133.Sh SEE ALSO
134.Xr powerd 8 ,
135.Xr pmf 9 ,
136.Xr sysmon_envsys 9 ,
137.Xr sysmon_taskq 9
138.Sh AUTHORS
139.An Jason R. Thorpe Aq Mt thorpej@NetBSD.org
140