How to make the laptop sleep when lid is closed

/etc/sysctl.conf:
Code:
hw.acpi.lid_switch_state=s3
hw.acpi.reset_video=1

did not help..

HP Envy 13-d004no FreeBSD 12 fails to raise up from suspend.

Is S3 listed among the supported suspend states?
Look in the output of:
sysctl hw.acpi.video.lid.levels

If S1 is listed, try it first. Also, don't enable hw.acpi.reset_video unless you already tried without: it might be the cause of a failed attempt. Give also a try to the the sleep button:
Code:
hw.acpi.sleep_button_state=S*
Maybe I should test TrueOS instead?
Unfortunately, unless you found the developed on their own an acpi driver for HP laptops, chances are very high it wouldn't work either
 
Code:
hw.acpi.lid_switch_state=S3
works on my HP EliteBook Folio 9470m with a small bug.
don't use it with hw.acpi.reset_video=1 it cause black screen when I use it, just use :
Code:
hw.acpi.lid_switch_state=S3
.
I have a little bug after get out to suspend my screen become black with a blank cursor on center of the screen, I looking for a solution to this issue :)
 
Additionally, in Plasma, Lock screen is under Button events handling.

(For me, S3 alone wasn't enough.)
 

Attachments

  • Plasma, power management, energy saving, button events handling.png
    Plasma, power management, energy saving, button events handling.png
    69.1 KB · Views: 44
At the risk of repeating what other's have said...

The following works with freebsd 13.2 on my thinkpad X201. I run the system using the windowmaker window manager.

For suspend on lid close, add the following line to /etc/sysctl.conf:-

hw.acpi.lid_switch_state=S3

As a bonus, I found Fn+F4 correctly suspends the system from the keyboard. So nice to see old(er) thinkpads well supported in freebsd, whoever wrote the code needs some recognition for doing a good job.

Basic resume then works on lid open with no other changes.

To maintain security after a resume on lid open (or, by hitting the Fn key alone if lid is already open), it is desirable to lock the screen immediately upon the resume. To achieve this, I run xidle from the window manager startup script, and arrange for xidle to invoke 'slock' when the xidle process is sent a SIGUSR1. Then we configure devd to raise the signal to the xidle process.

If you're using a desktop environment (KDE, XFCE, etc) you may run into conflicts with your DE's existing screenlock program. The solution presented here works with standalone window managers like windowmaker, fvwm etc., but you may be able to adapt it to other desktop environments.

To set up these things:-

0. install xidle and slock if they are not already installed.

1. in the window manager startup script (eg, windowmaker autostart script) add the line:-
xidle -se -program "/usr/local/bin/slock" -timeout 300 &,

(The timeout argument defines the inactivity screen lock period during normal use).

2. Create the following file.

/usr/local/etc/devd # cat acpi_lock.conf
notify 10 {
## Opening lid : Signal xidle to lock the terminal
match "system" "ACPI";
match "subsystem" "Lid";
match "notify" "0x01";
action "/bin/pkill -USR1 xidle";
};

You can probably guess that the effect of this is to invoke the pkill command to signal xidle when the lid is opened.

3. and you need to add
devd_enable="YES" to /etc/rc.conf,
and run "service devd restart"

This works well enough. When the lid is opened, the system resumes and the screen is immediately locked, to preserve security. Perhaps there are ways to break 'slock', but this is good enough for casual use.

For bonus points, you can add a "screenlock" launcher to your desktop or root menu that uses the same pkill command to signal xidle.
 
Back
Top