Update X when laptop lip is closed
Yuri Pankov
yuripv at yuripv.me
Mon Feb 17 00:04:39 UTC 2020
Noah Palmer wrote:
> On Sun, Feb 16, 2020 at 4:00 AM Yuri Pankov <yuripv at yuripv.me> wrote:
>
>> Noah Palmer wrote:
>>> On Sat, Feb 15, 2020 at 11:08 PM Yuri Pankov <yuripv at yuripv.me> wrote:
>>>
>>>> Noah Palmer wrote:
>>>>> is there a way to automatically remove or add the display to X when the
>>>>> laptop lid is opened or closed. I have been using a script to read
>>>>> dev.acpi_lid.0.state, but is there better way?
>>>>
>>>> If you are polling the dev.acpi_lid.0.state value, see /etc/devd.conf
>>>> for examples of ACPI events notification, so you could invoke the need
>>>> actions when lid is open/closed.
>>>>
>>> Okay that seems to be the solution. I also have an issue that
>>> dev.acpi_lid.0.state is incorrect if the lid was open at boot. you have
>> to
>>> close and open the lid for the value to be correct.
>>
>> Interesting, I'm seeing the same on my lenovo laptop, something to look
>> into. BTW, there's somewhat related PR filed:
>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240881.
>>
> Okay, I can use devd to run commands when the lid is opened and closed, but
> they don't trigger if the laptop starts open or closed, there has to be a
> change in state when the laptop is running.
Just tried that with a simple /etc/devd/lid.conf file:
notify 10 {
match "system" "ACPI";
match "subsystem" "Lid";
action "logger Lid $notify";
};
I seem to be getting the event right after the first state change,
booting both open and closed.
For the initial lid state, please try the attached patch (if possible).
-------------- next part --------------
commit 49e57132dc8b8d2e512c7fa5ed427e8346878d2e
Author: Yuri Pankov <yuripv at FreeBSD.org>
Date: Mon Feb 17 02:49:28 2020 +0300
acpi_lid: provide initial LID state
diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c
index 80bc344d606d..40ff2566889b 100644
--- a/sys/dev/acpica/acpi_lid.c
+++ b/sys/dev/acpica/acpi_lid.c
@@ -124,6 +124,9 @@ acpi_lid_attach(device_t dev)
if (acpi_parse_prw(sc->lid_handle, &prw) == 0)
AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit);
+ /* Get the initial lid status, ignore failures */
+ (void) acpi_GetInteger(sc->lid_handle, "_LID", &sc->lid_status);
+
/*
* Export the lid status
*/
More information about the freebsd-questions
mailing list