FreeBSD 15 + KDE: Laptop immediately suspends again after resume

Hey! I am using FreeBSD 15 on a ThinkPad T480 with KDE/X11.

When the lid closes, suspend works perfectly. However, when the laptop resumes from sleep, it goes back to suspend a few seconds later. Only after pressing the power button again does it finally resume.

I have tried setting sysctl dev.acpi_lid.0.wake=0 to prevent resume on lid open (so I resume with the lid open and press the power button). Same result.

I have also tried changing sysctl hw.acpi.lid_switch_state from NONE to S3.

I believe this is a KDE bug, because with the settings above everything works correctly in Openbox (no second suspend/resume cycle). It also works properly when I set “Do Nothing” in KDE Power Management, but in that case the screen is not locked on resume, which is not ideal -- I would prefer a proper solution.

Does anyone know what causes this second suspend?
 
It also works properly when I set “Do Nothing” in KDE Power Management, but in that case the screen is not locked on resume
/usr/local/etc/devd/kde_lock.conf:
Code:
notify 10 {
    match "system"    "ACPI";
    match "subsystem" "Lid";
    match "notify"    "0x00";
    action "su -l USER_NAME -c 'DISPLAY=:0 qdbus-qt6 org.kde.kscreenlocker /MainApplication lock' && sleep 2 && acpiconf -s 3";
};

/etc/sysctl.conf:
Code:
# hw.acpi.lid_switch_state=S3

# service devd restart
 
Thank you for the hint! I managed to make it work with a few tweaks.

Here’s a list of things that helped me, in case anyone else faces this problem:

1. Set the “When laptop lid closed” action to “Do nothing” everywhere in KDE Power Management settings.
2. Add /usr/local/etc/devd/kde_lock.conf with the following content:

Code:
notify 10 {
    match "system"    "ACPI";
    match "subsystem" "Lid";
    match "notify"    "0x00";
    action "/usr/local/bin/kde_lock";
};

3. Create an executable /usr/local/bin/kde_lock script with the following content:

Code:
#!/bin/sh

# Figure out the D-Bus socket file that belongs to the user.
dbus_sock=$(ls -l /tmp/dbus-* | grep kie6ran | cut -d' ' -f11)

su -l kie6ran -c "export DISPLAY=:0; export DBUS_SESSION_BUS_ADDRESS=unix:path=${dbus_sock}; export XDG_RUNTIME_DIR=/var/run/user/1001; qdbus6 org.freedesktop.ScreenSaver /ScreenSaver Lock"
su -l kie6ran -c 'sleep 2 && acpiconf -s 3'

Replace kie6ran with your username. The script isn’t optimized, but it works - feel free to adjust it.

That’s it!
 
Back
Top