Re: Handling the opening and closing of laptop lid

From: Anton Shepelev <anton.txt_at_gmail.com>
Date: Sat, 20 Jul 2024 12:07:42 UTC
Michael Schuster to Anton Shepelev

> > Has anybody been able to cause FreeBSD with X to handle
> > gracefully the closing and opeining of a laptop lid?
> > Althogh I have:
> >
> >               hw.acpi.lid_switch_state=s4
> >
> > on my HP 15bwoxx, closing the lid only turns the display
> > off, whereas the HDD continues to spin, the laptop still
> > buzzes, and upon opening the lid back up it goes into
> > operative state instantenously, with two new windows of
> > the "Settings/Display" application open in the centre of
> > the X screen.  How can I cause it to hibernate or at
> > least to stand by, and to prevent the launchhing of two
> > "Display" applications every time I open the lid?
>
> Are you using a desktop environment like KDE?

Yes, I have Xorg, Xfce, and lightdm.

> They usually have their own settings...

Yes, and I am puzzled how those settings interact with
sysctl's and lid-related ACPI events, which I can handle via
devd.

Under X, I have tried various settings in:

   Start menu
    Applications
     Settings
      Power Manager
       System
        Laptop Lid

Now I see that I was chaning it on the wrong tab, "On
battry" When I specified "suspend" for laptop lid action on
the "Plugged in" tab, closing the lid did send the laptop
into suspend mode, but it works only in X, and not in the
tty's.  When I open lid after suspect, a single "Display"
application window appears, and my camcontrol(8) settings
specified at boot are overridden, and half the time after
wake-up the Power Manager no longer shows the "Hibernate"
and "Suspent" options for the Lid, only "Switch off display"
and "Lock screen", whereas the Lid still causes the laptop
to suspend.

When I close the lid while in TTY, the laptop does not go
into suspend. When open the lid go back to X, it shows a
error notice from Power Manager:

   GDBus.Error:org.freedesktop.ConsoleKit.Manager.Error.InsufficientPermission: Not Authorised.

Whereas .xsession-errors has:

   (xfce4-power-manager:1674):
   xfce4-power-manager-WARNING **: 14:36:44.518:
   'CheckAuthorization' failed with GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed:
   Unix process subject does not have uid set

I considered setting:

              hw.acpi.lid_switch_state="NONE"

and handling everything by hand with devd, without the help
of X, but the abovementioned /Laptop Lid/ setting has no
option to do nothing, so for now I am stuck with a
dysfunctional lid in my laptop and shall welcome any help.