Updated: 2022/Sep/29

Please read Privacy Policy. It's for your privacy.


SYSMON_PSWITCH(9)          Kernel Developer's Manual         SYSMON_PSWITCH(9)

NAME
     sysmon_pswitch - framework for power switches

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 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:

           PSWITCH_TYPE_POWER
           PSWITCH_TYPE_SLEEP
           PSWITCH_TYPE_LID
           PSWITCH_TYPE_RESET
           PSWITCH_TYPE_ACADAPTER
           PSWITCH_TYPE_HOTKEY
           PSWITCH_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-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.

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
     powerd(8), pmf(9), sysmon_envsys(9), sysmon_taskq(9)

AUTHORS
     Jason R. Thorpe <thorpej@NetBSD.org>

NetBSD 10.99                    January 6, 2015                   NetBSD 10.99