Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Feb 2020 03:04:32 +0300
From:      Yuri Pankov <yuripv@yuripv.me>
To:        Noah Palmer <noahpalmerversion1@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Update X when laptop lip is closed
Message-ID:  <a5f78fee-edf5-a590-2c47-3ebe0aa9f0b2@yuripv.me>
In-Reply-To: <CACd7u-9em=-NvBZwb4H2S7pP5QqOLf3OHsBzBDFY5d44KL05ag@mail.gmail.com>
References:  <CACd7u-8CNo8OgqO21v%2BBpqesO-cUwKw-uUieYjqsSxiNFu1taw@mail.gmail.com> <2061301f-4f78-e50a-1864-f9a608b7c504@yuripv.me> <CACd7u--dZZiz6tcSgMeFazdsnyREEgOT0WoomEtAaa5VWSnbFQ@mail.gmail.com> <5fe7c2f2-9645-0c13-1878-7bbfa8f33487@yuripv.me> <CACd7u-9em=-NvBZwb4H2S7pP5QqOLf3OHsBzBDFY5d44KL05ag@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------48B82A192E22BF770C9228B6
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

Noah Palmer wrote:
> On Sun, Feb 16, 2020 at 4:00 AM Yuri Pankov <yuripv@yuripv.me> wrote:
> 
>> Noah Palmer wrote:
>>> On Sat, Feb 15, 2020 at 11:08 PM Yuri Pankov <yuripv@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).

--------------48B82A192E22BF770C9228B6
Content-Type: text/plain; charset=UTF-8;
 name="acpi_lid.diff"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="acpi_lid.diff"

Y29tbWl0IDQ5ZTU3MTMyZGM4YjhkMmU1MTJjN2ZhNWVkNDI3ZTgzNDY4NzhkMmUKQXV0aG9y
OiBZdXJpIFBhbmtvdiA8eXVyaXB2QEZyZWVCU0Qub3JnPgpEYXRlOiAgIE1vbiBGZWIgMTcg
MDI6NDk6MjggMjAyMCArMDMwMAoKICAgIGFjcGlfbGlkOiBwcm92aWRlIGluaXRpYWwgTElE
IHN0YXRlCgpkaWZmIC0tZ2l0IGEvc3lzL2Rldi9hY3BpY2EvYWNwaV9saWQuYyBiL3N5cy9k
ZXYvYWNwaWNhL2FjcGlfbGlkLmMKaW5kZXggODBiYzM0NGQ2MDZkLi40MGZmMjU2Njg4OWIg
MTAwNjQ0Ci0tLSBhL3N5cy9kZXYvYWNwaWNhL2FjcGlfbGlkLmMKKysrIGIvc3lzL2Rldi9h
Y3BpY2EvYWNwaV9saWQuYwpAQCAtMTI0LDYgKzEyNCw5IEBAIGFjcGlfbGlkX2F0dGFjaChk
ZXZpY2VfdCBkZXYpCiAgICAgaWYgKGFjcGlfcGFyc2VfcHJ3KHNjLT5saWRfaGFuZGxlLCAm
cHJ3KSA9PSAwKQogCUFjcGlFbmFibGVHcGUocHJ3LmdwZV9oYW5kbGUsIHBydy5ncGVfYml0
KTsKIAorICAgIC8qIEdldCB0aGUgaW5pdGlhbCBsaWQgc3RhdHVzLCBpZ25vcmUgZmFpbHVy
ZXMgKi8KKyAgICAodm9pZCkgYWNwaV9HZXRJbnRlZ2VyKHNjLT5saWRfaGFuZGxlLCAiX0xJ
RCIsICZzYy0+bGlkX3N0YXR1cyk7CisKICAgICAvKgogICAgICAqIEV4cG9ydCB0aGUgbGlk
IHN0YXR1cwogICAgICAqLwo=
--------------48B82A192E22BF770C9228B6--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?a5f78fee-edf5-a590-2c47-3ebe0aa9f0b2>