ACPILID(4)

πŸ“¦ version 11.0, in nixpkgs unstable

πŸ’– ACPILID(4) β€” the Kernel Interfaces Manual girlies' edition πŸ’–

okay so this page lives in the Kernel Interfaces Manual section, and it's all about acpilid β€” the ACPI Lid Switch driver, aka the little guy who knows when you close your laptop πŸ’…


✨ NAME ✨

acpilid β€” ACPI Lid Switch. that's it, that's the name, she's literally the lid-switch driver πŸŽ€


🌸 SYNOPSIS 🌸

acpilid* at acpi?

yes bestie, that's the whole config line. she attaches at acpi?, periodt ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so the acpilid driver is the one that supports ACPI "lid switches" β€” like, the physical lid of your laptop, the thing you flip open and shut fifty times a day without thinking about it πŸ™ˆ

you can hook the powerd(8) daemon up to it so it does stuff when the lid opens or closes. the script it runs is /etc/powerd/scripts/lid_switch, and the events it can fire are:

  • pressed β€” the lid was closed πŸ«₯
  • released β€” the lid was opened 🫢

that's the whole vibe check. two events, one script, infinite dramatic potential πŸ’€


πŸ“ EXAMPLES πŸ“

the following example modifies the mentioned script in order to put the system into (S3) sleep when the lid is closed β€” truly the main character move of power management πŸ‘‘

...

case "${2}" in
pressed)
        logger -p info "${0}: suspending..."

        # As in sleep_button, kill some daemons.
        #
        /etc/rc.d/dhcpcd stop
        /etc/rc.d/network stop
        /etc/rc.d/wpa_supplicant stop

        # Suspend.
        #
        if /sbin/sysctl hw.acpi.sleep.state >/dev/null 2>&1; then
                /sbin/sysctl -w hw.acpi.sleep.state=3
        fi

        # Waking up.
        #
        /etc/rc.d/wpa_supplicant start
        /etc/rc.d/network start
        /etc/rc.d/dhcpcd start

...

ngl this snippet ate πŸ’… it kills the daemons, checks hw.acpi.sleep.state exists with /sbin/sysctl hw.acpi.sleep.state >/dev/null 2>&1, sets /sbin/sysctl -w hw.acpi.sleep.state=3, then brings everything back up on the way out πŸ”₯


πŸ”₯ SEE ALSO πŸ”₯

go read those too bestie, iykyk πŸ“šβœ¨


🌈 HISTORY 🌈

the acpilid driver appeared in NetBSD 1.6 β€” she's been iconic since day one, no cap πŸ’œ


πŸ’Œ and that's the page! sourced from Debian, dated January 9, 2011 β€” go close your lid, she's got it from here πŸ«ΆπŸ¦‹πŸ’–
πŸ“¦ where this page comes from