The machine-independent
sysmon_pswitch provides a framework for power management. The interface has been largely superceded 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:
PSWITCH_HK_DISPLAY_CYCLE
display-cycle
PSWITCH_HK_LOCK_SCREEN
lock-screen
PSWITCH_HK_BATTERY_INFO
battery-info
PSWITCH_HK_EJECT_BUTTON
eject-button
PSWITCH_HK_ZOOM_BUTTON
zoom-button
PSWITCH_HK_VENDOR_BUTTON
vendor-button
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.