PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Awake not working

Open eirinn1975 opened this issue 4 years ago • 33 comments

Microsoft PowerToys version

0.41.4

Running as admin

  • [X] Yes

Area(s) with issue?

Awake

Steps to reproduce

Awake doesn't work out of the box for me. I selected stay awake for two hours, and after the usual "sleep" time the computer went off. Secondarily, I can't change the setting from the tray area icon, it just reflects what is set in the app itself.

✔️ Expected Behavior

should keep the computer alive

❌ Actual Behavior

computer goes to sleep mode regardless of the setting.

Other Software

No response

eirinn1975 avatar Jul 11 '21 14:07 eirinn1975

For the tray, this is tracked in #12145.

Can you clarify what the "usual sleep time" is? How did you select the 2 hour limit for Awake?

dend avatar Jul 13 '21 05:07 dend

Sorry if it wasn't clear. I've selected keep computer awake for the next 2hrs from the power toys main window app, under awake section. By usual sleep time (in my case after 20 idle minutes the computer goes to suspend mode) I meant the sleep time is specified in the windows settings in power management.

eirinn1975 avatar Jul 13 '21 06:07 eirinn1975

I can't reproduce this on my machine - can you share your logs, please? What is the version of PowerToys that you are using?

dend avatar Jul 14 '21 18:07 dend

As stated in the first message, version is 0.41.4. Where can I find the logs? I've tried looking in the PowerToys folder but haven't found anything

eirinn1975 avatar Jul 15 '21 07:07 eirinn1975

Hi @eirinn1975 , The logs would be included in a bug report. Could you please send one?

Right-click on the PowerToys icon in the tray menu and select Report Bug image Drag and drop report into a GitHub comment.

Thank you!

jaimecbernardo avatar Jul 15 '21 11:07 jaimecbernardo

PowerToysReport_2021-07-15-14-30-10.zip There you are :)

eirinn1975 avatar Jul 15 '21 11:07 eirinn1975

Looking at the logs, I don't see the timed keep-awake ever kicking in. Specifically, the last line in the app log is:

[2021-07-15 14:29:59.4582 INFO Awake.Core.APIHelper] Initiated indefinite keep awake in background thread: 25464. Screen on: False

This echoes what's in the Awake settings (see AwakeMode for reference on number mapping):

{"properties":{"awake_keep_display_on":false,"awake_mode":1,"awake_hours":2,"awake_minutes":0},"name":"Awake","version":"1.0"}

Which tells me that somehow the setting did not take effect. @eirinn1975 - can you try switching modes (from indefinite back to timed), and see if the issue persists?

dend avatar Jul 18 '21 05:07 dend

I'll make some tests today. Is the awake feature based on some service?

eirinn1975 avatar Jul 18 '21 05:07 eirinn1975

After a few tests: I set up suspension and screen off to 1 minute. turned on the awake function for both screen and indefinite time on awake. screen worked, and suspension avoided. I then turned off the keep screen awake function, it worked (screen went black). Then I disabled awake, and the computer stayed on. Seems now I'm in the opposite situation...

Here is the log after these tests. PowerToysReport_2021-07-19-08-54-53.zip

eirinn1975 avatar Jul 19 '21 05:07 eirinn1975

I am having the same issue on my machine running Win11

MountainDudeWV avatar Jul 21 '21 04:07 MountainDudeWV

Having the same issue win 10

weoinvm avatar Aug 04 '21 08:08 weoinvm

@weoinvm can you please provide some context as to what you are trying to do, what behavior you are seeing, and what system configuration do you have?

dend avatar Aug 04 '21 20:08 dend

I'm facing the same issue. I thought they've fixed it on the latest releases, but perhaps it's working the same way as before.

I'll provide logs soon, but I'll have to clear things first and generate a fresh one.

However, I believe this issue is related to system lock/hibernate settings/effects, not after a new startup.

I hibernate my machine a lot, and attempted to run it while I watched some stuff on Telegram Desktop, but the screen turns off even the setting of 1/2 hours is turned on.

What do you guys need besides the activity/dump logs? Anything else I could help you with to figure this out?

K0media avatar Aug 27 '21 20:08 K0media

@dend Any update? Since it's labeled prio-1 and 0.49 is around the corner...

Jay-o-Way avatar Oct 28 '21 12:10 Jay-o-Way

No major update yet as I haven't been able to pinpoint the issue. We might get it out post-0.49 as I am in the process of drafting up the spec for the next Awake version.

dend avatar Oct 28 '21 17:10 dend

I have the same problem.

Awake does not keep the computer awake. Does not appear to make any difference what I set it to. Computer goes to sleep after the usual amount of time.

(I realise this isn't a particularly helpful report - let me know if you want logs or anything - I'm just adding it here to indicate that I'm another person finding that this tool doesn't do what it's designed to do)

ned-martin avatar Nov 30 '21 09:11 ned-martin

Same behavior with my Surface Book 2...

ironboy1 avatar Dec 07 '21 09:12 ironboy1

Just to put in my two penny's worth. I am having the same issue with Windows 11 (all updates as of 12 Dec 2021) and Awake 0.51.1. After some work I think the issue only happens after the PC awakes from a sleep state. It works fine after a cold start. I hope this helps find the issue.

manic232 avatar Dec 12 '21 13:12 manic232

I have same issue here on one computer.

Maybe it's related to Modern Standby (S0 power state), because it works without issue on other computers that don't support modern standby...

CRi83 avatar Dec 17 '21 02:12 CRi83

@dend Do you know if both sleep and hybernation should be prevented? Since they are different settings and the latter one is buried deep in advanced System Configuration settings... image

Jay-o-Way avatar Dec 17 '21 12:12 Jay-o-Way

Happy and Healthy New Year!

I just ran into this issue - but under different/very specific circumstances - so perhaps my observations could help to solve this:

What I'm trying to do is to use Awake to prevent sleep mode while doing a backup from a remote server via rsync:

(1) wake up sleeping computer via magic packet/wakeonlan (2) connect via ssh (Cygwin), start Awake to keep it in this state (3) run backup (ssh/rsync) (4) connect via ssh (Cygwin), kill Awake (5) computer resumes sleeping

I've been using this setup (with DontSleep instead of Awake) for years on various other/older laptops.

However, with my newest laptop this starts to behave "strange":

The above flow still works like a charm when the computer is not yet sleeping in the first place.

BUT: It reproducibly fails when it has just been woken up by (1):

  • Awake is started properly by (2) (ssh to the machine running "tasklist" shows it)
  • Awake in the logs even reports "Initiated indefinite keep awake in background thread..." and no errors
  • Running "powercfg -requests" (again via ssh) shows Awake is requesting SYSTEM as expected
  • BUT: The computer still falls back to sleep within a few seconds!

Observations:

  • When you manually wake up the computer again later (e. g. by keyboard) after the above "failure", Awake is still running and even prevents the computer from falling asleep again!
  • Having --display-on or not does not make a difference; after the wakeonlan the screen remains black/off.
  • Using --pid 0 (idle) or 4 (kernel) does not make a difference.
  • This is the case on both, Windows 11 Pro as well as Windows 10 Pro (both freshly installed, all updated with no other software installed, except Cygwin + PowerToys).
  • (DontSleep has exactly the same issue; it even requests AWAYMODE...)

What eventually "fixed" it for me was a BIOS setting: There is a "Sleep State" option in the BIOS, with two settings:

  • "Windows and Linux" - [for systems] "that at are compatible with Suspend-To-Idle", ("powercfg /availablesleepstates" reports S0 enabled, S1+S2+S3 disabled)
  • "Linux S3" - [for systems] "that are not compatible with Suspend-To-Idle" ("powercfg /availablesleepstates" report S0 not available, S1+S2 disabled, S3 enabled)

Using the default "Windows and Linux" I see the above behavior, however switching this to "Linux S3" things are working (again) as expected!

My conclusion: @CRi83 could be pointing in the right direction: When Windows is (already) in S0 "sleep" mode, it seems to ignore (changes to) SetThreadExecutionState!?

To prevent this, Awake could try to "wake the computer up completely" (whatever that means) before setting SetThreadExecutionState?

abenneke avatar Jan 04 '22 23:01 abenneke

Interesting - thank you for the observation and detailed report @abenneke. I am currently investigating if there is a way to do this.

dend avatar Jan 29 '22 01:01 dend

An interesting tidbit in the official docs:

Windows prevents desktop applications from running during any part of modern standby after the DAM phase completes.

Wonder if this has anything to do with observed behavior. It also seems like I need to expand logging to see when the behavior occurs before this can be addressed, and for that I need to get the SYSTEM_POWER_STATE. Just need to figure out which API returns that.

dend avatar Jan 29 '22 02:01 dend

Does not work for me as well.

If I set "Keep screen on" to true, then the display still goes dark after predefined time.

The logs constantly state:

[2022-03-11 20:16:18.3749 INFO Awake.Program] Detected a settings file change. Updating configuration...
[2022-03-11 20:16:18.3749 INFO Awake.Program] Resetting keep-awake to normal state due to settings change.
[2022-03-11 20:16:18.3749 INFO Awake.Program] Operating in passive mode (computer's standard power plan). No custom keep awake settings enabled.

So it seems that it acutally never enables the keep-awake state?

Anything I can do to help debug the issue?

Morgy93 avatar Mar 11 '22 19:03 Morgy93

@Morgy93 are you setting a specific mode of operation other than passive after setting the display on? Are you doing this through the tray or the PowerToys settings?

Also - what OS version do you have?

dend avatar Mar 12 '22 02:03 dend

@Morgy93 are you setting a specific mode of operation other than passive after setting the display on? Are you doing this through the tray or the PowerToys settings?

Also - what OS version do you have?

OS: Windows 11 Home 21H2 22000.556

I used the tray icon and only enabled "Keep screen on". I'll see if it makes a difference if set via PowerToys directly. PowerToys is not run with administrator privileges.

Edit: It seems to work if I also change the power plan accordingly - is this intended or a bug? If intended, the UX should be improved. It does not seem to make a difference if set via tray icon or PowerToys directly.

Morgy93 avatar Mar 12 '22 06:03 Morgy93

@Morgy - "Keep Screen On" should only work when you have the active mode selected (either timed or indefinite) and not passive. I'll think through this a bit more from the UX perspective - maybe the option should not be available to keep the display on unless you've selected a compatible mode.

dend avatar Mar 12 '22 20:03 dend

@morgy - "Keep Screen On" should only work when you have the active mode selected (either timed or indefinite) and not passive. I'll think through this a bit more from the UX perspective - maybe the option should not be available to keep the display on unless you've selected a compatible mode.

Yes, that would be great! Shall I open another issue for it? That makes it clear so that the option is bound to an enabled Awake state.

Morgy93 avatar Mar 13 '22 11:03 Morgy93

@Morgy93 yes please - a new issue would be great here.

dend avatar Mar 17 '22 20:03 dend

Glad I found this. So looks like this PowerToy isn't working at all. I tried to keep my Surface Book 3 awake to test something while I was away, but my test failed and apparently because Awake didn't keep the machine awake. The Event log shows that my Surface Book entered connected standby mode regardless. I think this tool doesn't work with modern standby.

The system is entering connected standby 

Reason: Idle Timeout.

marcelgood avatar Nov 06 '22 21:11 marcelgood