You are not logged in.

#1 2024-10-01 14:35:43

eUser4
Member
Registered: 2024-03-10
Posts: 14

[SOLVED] Sleep kbd button multi press causing system not to wake up

I have a PS/2 keyboard with sleep button.
If I accidentally make a multi-press of a button this cause a situation where system does go [deep] sleep but won't wake up. I have to use power button to start  computer.
If I am careful to not cause multi press then system go to sleep as well, but can(correctly) wake up by pressing any kbd button(as I have it set so and was working since ever, on Windows too).
This is 100% reproducible. With single(fast) press I can wake up computer multiple times in row, the moment I dare to do a mistake and cause multi press to register, computer won't wake up on any kbd button press - I have to power on on the case.

I use LXQT + SDDM but it also happened without display manager installed as well.

I have seen a lot of issues on the net about not able to power on from standby and wonder if it could be this. Of course I could use menu, but kbd button is more convenient.

Any idea?

EDIT: Also, I cannot reproduce this under XFCE + LXDM at all, that I have on another disk.

Last edited by eUser4 (2024-10-18 20:32:16)

Offline

#2 2024-10-03 10:01:05

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

I maybe have found the reason by searching online, but I am on the trip and cannot test it before late October.

I found from this: https://man.archlinux.org/man/logind.conf.5 ,that HandleSuspendKeyLongPress= defaults to "hibernate".
As I have a fairly short kbd repeat delay(300ms), there is a possibility that I am causing hibernate on top of suspend, or hibernation alone. Maybe systemd is not locking after initialization correctly, which would still mean bug.
After reading wiki about XFCE I found this one is handling suspend itself, whereas in LXQT this is likely done via systemd.

Offline

#3 2024-10-16 19:24:10

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Ok so I tried modes like forcing s2idle and changing sleep.conf disabling HandleSuspendKeyLongPress and pretty much everything else. Nothing helped. I don't know if its LXQT or SystemD fault, I just know XFCE works fine.

Offline

#4 2024-10-16 22:07:44

seth
Member
Registered: 2012-09-03
Posts: 58,658

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

If you completely disable the suspendkey handling (don't forget to reload the daemon), does it still do sth. (notably sending the system to sleep on a short press)?
But the "long" duration here is 5 seconds, https://github.com/systemd/systemd/blob … tton.c#L51 - you're not that clumsy, are you?

As for the autorepeat in X11 (assuming the key is bound to some session-specific shortcut):
Does it help if you set the X11 autorepeat delay to 1000ms?

You can disable the autorepeat for individual keycodes, sleep is likely 150, but you'd best figure by running "xev -event keyboard" and pressing that key in a naked session ("startx xterm", no desktop at all)

Online

#5 2024-10-16 23:21:35

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Greetings Seth, to your first question seems it does:
I found that disabling all power modes in sleep.conf in /etc/systemd to:
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

+ additionally in GUI of LXQT->power management->power keys disabling suspend key action to "nothing"(same was already for hibernate action, only power key action is set to "shutdown"),
made no difference in that pressing the sleep button still did shut down computer(which I assume went to sleep). That after both daemon-reload and even restart.

One thing this did however was that this time, I could not wake up computer regardless of fast - single press to issue sleep.

When I reverted changes back(that is commented out above lines in sleep.conf which basically turned on all modes) and re-enabled sleep button in LXQT GUI, I am back to where single quick press put in sleep mode where I can wake up back and accidental "double-click" cause system not be able to wake on kbd press. So like before.

I have not yet tried delay, but that won't do because on my kbd(MS natural multimedia keyboard 1.0) sleep button is quite embeded into surrounding plastic and is easy to couse double-click, so solving delay alone is unlikely enough.
I consider this still a bug because once button is registered, it should properly lock into ongoing suspend process and not start doing another thing. XFCE handle this correctly. I just don't know if its LXQT or SystemD issue.

Additionally as a side note I also found that setting in sleep.conf modes like mentioned 'MemorySleepMode=s2idle' do not overwrite /sys/power/mem_sleep, not after daemon-reload nor restart. Only echo s2idle > /sys/power/mem_sleep works.

Offline

#6 2024-10-17 06:04:38

seth
Member
Registered: 2012-09-03
Posts: 58,658

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Ok, we'll first have to figure what actually handles the key.
Boot the multi-user.target, run evtest on the keyboard, then see
1. whether the key suspends the system from the multi-user.target
2. what event it registers (you can tee the output of evtest into some file to log it for later)

Do you run anything lile acpid, keyd etc?

Sidebar:

XFCE + LXDM at all, that I have on another disk … on Windows too

Regardless of how many disks, this counts as dual booting so make sure to see the 3rd link below. Mandatory.
Disable it (it's NOT the BIOS setting!) and reboot windows and linux twice for voodo reasons.

Online

#7 2024-10-17 14:51:48

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Hello again Seth. Ok so I found something interesting.
First, check the attached screenshot:
screengrab

LXQT acpi buttons relly on 2 independent settings, you need to setup a button shortcut(if its not by default) in shortcuts settings(Global action manager), and then separately in power management enable and chose which acpi button mode to which event will be assigned. If you don't setup both, button doesn't work. This is how I was actually able to disable sleep button. Then running evtest showed its registration to code 142 but system did not went to sleep. So it is controlled via LXQT GUI.

Now I also found that my sleep button is assigned to XF86sleep. By default, what you see on screenshot is default setup of LXQT, except that I disabled XF86PowerOff and XF86Suspend manually. You can see that by default it assign(in my opinion wrongly) XF86Sleep to /powermanager/keyhibernate and XF86Suspend to /powermanager/keysuspend. Those /powermanager/... are not a dirrect shell command and are not editable. My guess is that they link to Power Manager window.

Problem is that Power Manager window does not correctly register those 3 events either. You can see on the picture that(I set it so) only Power key is set to suspend. This is because other 2 have no effect, in another words XF86Sleep in shortcuts is triggering Power key action in Power Manager and not for example Suspend key action or even Hibernate Key action(as it actually should as key is registered to /powermanager/keyhibernate and not /powermanager/keypoweroff).

So its all wrong. Of course by default in Power Manager, Power key action was set to Shutdown, then what I think was happening was that double press was initiating shutdown on top of sleep.

So now with that said, I tried:
-disabling  XF86PowerOff and XF86Suspend and left only XF86Sleep shortcut enabled.
-disabled Suspend and Hibernate key action in power manager and set Power key action to Suspend(since that is what trigger key press).

With this setting I can initiate sleep but waking up still does not work correctly. What it does now is that upon first kbd press it does wake up computer, which start up and is running without turning on monitor for few seconds, then it shut down on its own again. After pressing any kbd button second time, this time computer wake up fully, including monitor. My guess is that this is still because button is registered to /powermanager/keyhibernate and is triggering Power Key action. But at least I am getting closer. This definitely seems to be LXQT issue now, not SystemD.

I would like to figure out how to set XF86Sleep to /powermanager/keysuspend and how to get Power Manager settings to register this to Suspend Key action instead Power Key action. Worst case I may just try to trigger systemctl sleep command(via shortcuts) and bypass LXQT, if that will work.

Any more tips on this are welcome.

EDIT: To your questions, no keyd or acpid installed and no faststart(or even fastboot in bios), I in fact already deleted windows. I have arch with xfce on one disk and arch with lxqt on another. And do cold start/reset.

EDIT2: Now with this setup(as in above pic) I can wake up with kbd even if I pressed multiple times during sleep. But as mentioned, computer will shut down and then I have to press again to wake it fully.

Last edited by eUser4 (2024-10-17 15:01:04)

Offline

#8 2024-10-17 20:04:28

seth
Member
Registered: 2012-09-03
Posts: 58,658

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

But as mentioned, computer will shut down and then I have to press again to wake it fully.

What sounds like hibernation.
Disable all power keys (sleep, suspend & poweroff) in the global actions manager and set all power keys to "nothing" in the power manager.
The key should not do anything anymore, right?

Then in the global actions bind XF86Sleep to /powermanager/keysuspend (I guess the "modify" button allows that)
=> Profit?
Alternatively disable the key in the global actions again and set Hibernate key action in the powermanager to "suspend".
=> Profit?

Idk how these things actually tie together, whether those are two UIs controlling the same setting in lxqt (you'll have to report and ask upstream) but worst case, bind the XF86Sleep key to "systemctl suspend" in the global actions menu.

Online

#9 2024-10-18 10:56:52

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Greetings again Seth,

Yes I also believe its probably hibernation, after all that's what it is set to in shortcuts.
For a button to work, it have to be enabled in both shortcuts(Global Action Manager) and Power Manager. Specifically XF86Sleep in shortcuts and Power Key action in power manager. If either of 2 is not set, button does nothing.

You cannot modify existing XF86Sleep in shortcuts, you can enable/disable it but both Command and DBus check boxes are greyed out/non editable.
Also, key respond only to Power Key action in Power Manager, Suspend Key action and Hibernate Key action does nothing, that's why I think its a bug.

The only options I see are either your last suggestion, or I would prefer if I could set XF86Sleep to /powermanager/keysuspend instead of keyhibernate. But that is not a command/path, probably dbus but I don't know how to set it such way.

Offline

#10 2024-10-18 13:57:46

seth
Member
Registered: 2012-09-03
Posts: 58,658

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

https://github.com/lxqt/lxqt-globalkeys

Though on the screenshot it looks like XF86Sleep is bound to the "Hibernate key action" and in the power manager  that is set to nothing?

Online

#11 2024-10-18 14:45:09

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Indeed XF86Sleep is by default bound to keyhibernate, not keysuspend(in shortcuts). But not in corresponding Power manager. By default Power manager have Power Key Action set to Shutdown, Suspend Key Action to Suspend and Hibernate Key Action to Hibernate. However pushing button in reality react to Power Key action. So for example if you set Power Key Action to nothing but set both Suspend and Hibernate Key Actions to something, pressing sleep button do nothing. Functionality of XF86Sleep in shortcuts is binded to Power Key Action(only) in Power Manager - which is clearly wrong.

I found by editing XF86Suspend in shortcuts by setting its key to XF86Sleep, as opposed to editing existing XF86Sleep to trying to set it to /powermanager/keysuspend(which is not possible) I can set that key to keysuspend(and having the other one disabled). But it still again does same thing during wake up and doesn't work correctly. That is, even by having XF86Sleep set to /powermanager/keysuspend this time. Maybe because in Power Manager it still have to be Power Key Action set to suspend and not Suspend Key Action. Waking up cause auto shutdown/double wake up even like this. Its all wrong and messy so probably the last option is to set systemctl command. Otherwise I don't know.

Offline

#12 2024-10-18 16:03:01

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

I found more things:

shortcuts will reset key binding on its own if I set XF86Suspend to XF86Sleep. Instead I disabled default XF86Sleep shortcut and added new for XF86Sleep+ bind it to command "systemctl suspend".

Secondly, that "double wake up" problem is likely a SystemD problem. By having XF86Sleep set to systemctl suspend and having *all* key actions disabled in Power Manager, this should be now all handled by systemd only and double wake up happen if I press multiple times during sleep initialization(and not when I press quickly once only).

I tried to set settings in /etc/systemd/logind.conf:
SleepOperation=suspend
HandlePowerKey=poweroff
HandlePowerKeyLongPress=ignore
HandleRebootKey=reboot
HandleRebootKeyLongPress=ignore
HandleSuspendKey=suspend
HandleSuspendKeyLongPress=ignore
HandleHibernateKey=
HandleHibernateKeyLongPress=ignore

and /etc/systemd/sleep.conf:
AllowSuspend=yes
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no

Nope, doesn't help. I don't know what to do at this point.

Offline

#13 2024-10-18 16:27:35

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

And finally, I also tried to put a direct command in shortcuts: sh -c 'sudo echo mem | tee /sys/power/state' and found "double wake up" still happen. So not even systemd issue, I dont know anymore. Maybe kernel or that system as a whole is not locking initiation of(first) sleep correctly. Clearly xfce handle this on its own that's why it work fine there.

Offline

#14 2024-10-18 16:37:53

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Seth, I am pleased to found the "double wake up" problem source, its a kernel.

If you do(from shell): 'sudo echo mem | sudo tee /sys/power/state', system wake up on single kbd press fully as it should.
But if you do: 'sudo echo mem | sudo tee /sys/power/state && sudo echo mem | sudo tee /sys/power/state', indeed it start, shutdown, and then start properly only after another kbd press.

This means xfce is locking keyboard to prevent further sleep presses to avoid this problem, but lxqt do not(and neither does systemd). I don't know who's to blame, maybe its a kernel that should lock itself properly on first initiation.

EDIT: And this problem doesn't exist if you use menu with mouse click. Clearly they did not accounted for kbd keys issues.

Last edited by eUser4 (2024-10-18 17:26:45)

Offline

#15 2024-10-18 18:17:36

seth
Member
Registered: 2012-09-03
Posts: 58,658

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

xset -r <keycode>

You can get the keycode from xev (as long as no global shortcut is assigned), likely 150

Online

#16 2024-10-18 20:18:58

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Dear Seth, guess what your solution actually helped.
When setting xset -r 150, enabling default XF86Sleep in shortcuts(even though it point to /powermanager/keyhibernate) and setting Power Key action in Power Manager to Suspend, system now wake up correctly. And not only with sleep kbd key held longer, but surprisingly also if I try to intentionally "double click" it by doing "multi press".

Sure, its a workaround and LXQT's Power Manager with Global Actions interconnections are still mess pointing to wrong stuff, but sleep+wake-up seem to work correctly now.

So all I can say is big thank you and whether this topic can be marked as solved I leave entirely up to you.

Last edited by eUser4 (2024-10-18 20:20:07)

Offline

#17 2024-10-18 20:24:33

seth
Member
Registered: 2012-09-03
Posts: 58,658

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

whether this topic can be marked as solved I leave up to you

Nope, that's actually up to you - only tongue

Though I guess there's not much more we can do here.
* About LXQT's Power Manager with Global Actions interconnections you'll have to file a bug upstream for them to sort that out.
* Has the double-press actually caused the issue before? Or only the synthetic autorepeat?

So in case and please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Online

#18 2024-10-18 20:30:36

eUser4
Member
Registered: 2024-03-10
Posts: 14

Re: [SOLVED] Sleep kbd button multi press causing system not to wake up

Both double press and repeat I believe, whenever I did anything other than *extremely* fast stable click, I got into trouble.

Offline

Board footer

Powered by FluxBB