| SYSMON_PSWITCH(9) | Kernel Developer's Manual | SYSMON_PSWITCH(9) |
sysmon_pswitch —
framework for power switches
#include
<dev/sysmon/sysmonvar.h>
int
sysmon_pswitch_register(struct
sysmon_pswitch *smpsw);
void
sysmon_pswitch_unregister(struct
sysmon_pswitch *smpsw);
void
sysmon_pswitch_event(struct
sysmon_pswitch *smpsw,
int event);
The machine-independent sysmon_pswitch
provides a framework for power management. The interface has been largely
superseded by the pmf(9)
framework, but sysmon_pswitch is still used to
manage power switches as well as related mechanical adapters and buttons.
These are encapsulated in the following structure:
struct sysmon_pswitch {
const char *smpsw_name; /* power switch name */
int smpsw_type; /* power switch type */
LIST_ENTRY(sysmon_pswitch) smpsw_list;
};
Unsurprisingly, smpsw_name specifies the name of the power switch and smpsw_type defines the type of it. The following types are defined:
If the type is PSWITCH_TYPE_HOTKEY, there
are few predefined names that can be used for
smpsw_name:
Once a power switch event has been proceeded,
sysmon_pswitch will inform the user space
powerd(8), which will possibly
execute a script matching the type of the power switch.
After the
sysmon_pswitch
structure has been initialized, a new power switch device can be registered
by using
sysmon_pswitch_register().
The device can be detached from the framework by
sysmon_pswitch_unregister().
The
sysmon_pswitch_event()
is used to signal a new power switch event. There are two possibilities for
the value of event:
The corresponding events in powerd(8) are pressed and released.
Jason R. Thorpe <thorpej@NetBSD.org>
| January 6, 2015 | NetBSD 11.0 |