You are not logged in.

#1 2023-03-03 10:06:22

leminhman0312
Member
Registered: 2020-07-12
Posts: 22

System uses action for HandleLidSwitch regardless if machine is plugge

My system runs 6.1.12 Arch Linux, i3wm.

This is my /etc/systemd/sleep.conf

[Sleep]
AllowSuspend=yes
AllowHibernation=yes
AllowSuspendThenHibernate=yes
#AllowHybridSleep=yes
SuspendMode=suspend
#SuspendState=disk
#SuspendState=mem standby freeze
#HibernateMode=suspend
#HibernateState=disk
#HybridSleepMode=suspend platform shutdown
#HybridSleepState=disk
HibernateDelaySec=10sec

and this is my /etc/systemd/logind.conf

[Login]
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend
HandleLidSwitchDocked=suspend

When I close the lid, system goes into suspend and after 10 seconds, it goes to hibernate.
I only want this behavior to happen when I am not plugged in or connected to dock. So, I set my logind.conf as above.
However, when I am plugged in via AC, the system does the suspend-then-hibernate instead of suspend only. Havent tested with dock yet.
Any suggestions to fix is welcome.

Offline

#2 2023-03-03 22:04:03

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,429

Re: System uses action for HandleLidSwitch regardless if machine is plugge

You have  left "#AllowHybridSleep=yes" as per default, which is a different target than "AllowSuspendThenHibernate=", and

systemd-sleep(8) for "HibernateDelaySec=10sec" wrote:

The amount of time the system spends in suspend mode before the system is automatically put into hibernate mode. Only used by systemd-suspend-then-hibernate.service(8).

Perhaps you need "AllowHybridSleep=no"?

Offline

#3 2023-03-04 07:05:27

leminhman0312
Member
Registered: 2020-07-12
Posts: 22

Re: System uses action for HandleLidSwitch regardless if machine is plugge

Strike0 wrote:

You have  left "#AllowHybridSleep=yes" as per default, which is a different target than "AllowSuspendThenHibernate=", and

systemd-sleep(8) for "HibernateDelaySec=10sec" wrote:

The amount of time the system spends in suspend mode before the system is automatically put into hibernate mode. Only used by systemd-suspend-then-hibernate.service(8).

Perhaps you need "AllowHybridSleep=no"?

Thanks for suggestion.  Unfortunately, putting

AllowHybridSleep=no

doesnt do anything.  In other words, my laptop, when plugged in, still does

suspend-then-hibernate

instead of just

suspend

only.

Offline

#4 2023-03-04 08:30:54

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: System uses action for HandleLidSwitch regardless if machine is plugge

If you set

HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

and restart logind (or reboot), is the lid ignored on external power?
Cause if not, the state is simply not properly detected.

Sanity check: is there a parallel windows installation?

Offline

#5 2023-03-04 08:41:17

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,429

Re: System uses action for HandleLidSwitch regardless if machine is plugge

Ok. A couple questions: What's in the journal for the whole suspend-hibernate cycle after resume? How do you test changed settings (daemon-reload and logout/login)? What happens when you suspend manually from the terminal while docked, does it stay in suspend or hibernate as well?

Have a look at

systemd-inhibit --list

if there is something else handling the lid switch and hibernate key.

Offline

#6 2023-03-05 06:46:59

leminhman0312
Member
Registered: 2020-07-12
Posts: 22

Re: System uses action for HandleLidSwitch regardless if machine is plugge

seth wrote:

If you set

HandleLidSwitchExternalPower=ignore
HandleLidSwitchDocked=ignore

and restart logind (or reboot), is the lid ignored on external power?
Cause if not, the state is simply not properly detected.

Sanity check: is there a parallel windows installation?

Hi.  I did set  like you asked and restarted, and the lid is not ignored on external power.  In other words, on AC power, closing the lid would put the laptop in suspend mode.  This is just like without on AC.  I can open the lid and reenter my password to resume.  I know my laptop is in suspend because the Thinkpad's LED flashing on and off.

I have a dual boot Windows 11.

Offline

#7 2023-03-05 06:50:11

leminhman0312
Member
Registered: 2020-07-12
Posts: 22

Re: System uses action for HandleLidSwitch regardless if machine is plugge

Strike0 wrote:

Ok. A couple questions: What's in the journal for the whole suspend-hibernate cycle after resume? How do you test changed settings (daemon-reload and logout/login)? What happens when you suspend manually from the terminal while docked, does it stay in suspend or hibernate as well?

Have a look at

systemd-inhibit --list

if there is something else handling the lid switch and hibernate key.

Hello. I suspend/hibernate from terminal using

 sudo systemctl suspend 
 sudo systemctl hibernate 

Both work well.  This is the log of

 systemd-inhibit --list
WHO                 UID  USER    PID  COMM            WHAT                                                                       WHY                                       MODE
NetworkManager      0    root    886  NetworkManager  sleep                                                                      NetworkManager needs to turn off networks delay
UPower              0    root    1396 upowerd         sleep                                                                      Pause device polling                      delay
xfce4-power-manager 1000 maxwell 1330 xfce4-power-man handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch xfce4-power-manager handles these events  block
xfce4-screensaver   1000 maxwell 1477 xfce4-screensav sleep                                                                      Locking screen before sleep               delay

4 inhibitors listed.

Offline

#8 2023-03-05 07:14:04

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: System uses action for HandleLidSwitch regardless if machine is plugge

xfce4-power-manager 1000 maxwell 1330 xfce4-power-man handle-power-key:handle-suspend-key:handle-hibernate-key:handle-lid-switch xfce4-power-manager handles these events  block

Offline

#9 2023-03-05 11:04:13

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,429

Re: System uses action for HandleLidSwitch regardless if machine is plugge

Yes, that reads like there may be a clash between xfce4's power-manager and the logind.conf lid actions. https://wiki.archlinux.org/title/Xfce#L … gs_ignored describes the opposite and will help to test changing xfce's setting there.

Offline

#10 2023-03-06 11:27:28

leminhman0312
Member
Registered: 2020-07-12
Posts: 22

Re: System uses action for HandleLidSwitch regardless if machine is plugge

Strike0 wrote:

Yes, that reads like there may be a clash between xfce4's power-manager and the logind.conf lid actions. https://wiki.archlinux.org/title/Xfce#L … gs_ignored describes the opposite and will help to test changing xfce's setting there.

Hi, thanks for your reply.  I followed the link and still could not get it to work.  In the link, we want system to follow whatever is set for xfce4-power-manager (e.g. suspend when on battery, hibernate on AC power..etc) and NOT followed systemd.   

In my case, I want the system to follow systemd because my sleep.conf wants:  suspend-then-hibernate on battery, and suspend only on AC.  This is opposite to the link, so I set:

xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/logind-handle-lid-switch -s true

I then tested it:  a) right after execute the above command and b) after a full restart.  In both cases, closing the lid on AC will always do the suspend-then-hibernate instead of just only suspend.  In other words, it ignores whatever is set in sleep.conf. 

Another way is to just not use xfce4-power-manager at all.  For this case, if I set

HandleLidSwitchExternalPower=ignore

then yes, after closing lid on AC, the machine is on, aka it ignores. 

Wondering how I could get this to work with xfce4-power-manager because on i3wm, setting locker  is a hit and miss for me.  Meanwhile, the xfce4-power-manager gets suspend and hibernate working every single time.

Last edited by leminhman0312 (2023-03-06 11:55:32)

Offline

#11 2023-03-06 14:02:51

seth
Member
Registered: 2012-09-03
Posts: 50,957

Re: System uses action for HandleLidSwitch regardless if machine is plugge

Meanwhile, the xfce4-power-manager gets suspend and hibernate working every single time.

Then why is this thread?

I guess you mean the invocation of some screen locker when suspending?
https://wiki.archlinux.org/title/Power_ … stem-sleep
https://gist.github.com/AladW/de1c5676d93d05a5a0e1

Offline

#12 2023-03-07 10:23:12

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,429

Re: System uses action for HandleLidSwitch regardless if machine is plugge

I find it confusing that the systemd-inhibit lists xfce4-power-manager while you use i3wm, but ok. So, the main problem remained when toggling "xfce4-power-manager/logind-handle-lid-switch".

If you want to rely on systemd for power management, what I would do is troubleshoot the systemd sleep.conf/login.conf on the console, i.e. without any WM:
First, remove any hibernate actions and configure it only for suspend-resume (whether on AC or battery, lid closed or button pressed) and not worry about screen locking for that. Once the suspend works consistently everytime, start i3wm again and check it continues to suspend only on AC.
Once that works, look into the screen locking and, finally, how to enable hibernate-after-suspend on battery.
That will hopefully find the culprit in your sleep.conf

Offline

Board footer

Powered by FluxBB