SYSMON_PSWITCH(9)
πΈ NAME πΈ
okay bestie, this is SYSMON_PSWITCH(9) from the Kernel Developer's Manual, and the name says it all: sysmon_pswitch is literally the framework for power switches β¨. Thatβs the whole vibe. π
β¨ SYNOPSIS β¨
#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);
π DESCRIPTION π
the machine-independent sysmon_pswitch gives you a framework for power management. heads up though: the interface has been largely superseded by the pmf(9) framework, but sysmon_pswitch is still used to manage power switches, plus related mechanical adapters and buttons. all of that is encapsulated in this struct π«Ά:
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:
PSWITCH_TYPE_POWERPSWITCH_TYPE_SLEEPPSWITCH_TYPE_LIDPSWITCH_TYPE_RESETPSWITCH_TYPE_ACADAPTERPSWITCH_TYPE_HOTKEYPSWITCH_TYPE_RADIO
If the type is PSWITCH_TYPE_HOTKEY, there are few predefined names that can be used for smpsw_name:
PSWITCH_HK_DISPLAY_CYCLEβdisplay-cyclePSWITCH_HK_LOCK_SCREENβlock-screenPSWITCH_HK_BATTERY_INFOβbattery-infoPSWITCH_HK_EJECT_BUTTONβeject-buttonPSWITCH_HK_ZOOM_BUTTONβzoom-buttonPSWITCH_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. π
π«Ά FUNCTIONS π«Ά
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:
PSWITCH_EVENT_PRESSEDβ A button has been pressed, the lid has been closed, the AC adapter is off, etc.PSWITCH_EVENT_RELEASEDβ A button has been released, the lid is open, the AC adapter is on, etc.
The corresponding events in powerd(8) are pressed and released.
π SEE ALSO π
π AUTHORS π
Jason R. Thorpe <thorpej@NetBSD.org> β iconic. π
okay bye bestie β this page is from the Debian edition, dated January 6, 2015, and itβs SYSMON_PSWITCH(9). mwah π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms