Handling the opening and closing of laptop lid

From: Anton Shepelev <anton.txt_at_gmail.com>
Date: Sat, 20 Jul 2024 10:37:29 UTC
Hello, all.

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?