Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to prevent sleep if task is running #16376

Closed
Sergio0694 opened this issue Nov 25, 2023 · 9 comments
Closed

Option to prevent sleep if task is running #16376

Sergio0694 opened this issue Nov 25, 2023 · 9 comments
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-External For issues that are outside this codebase

Comments

@Sergio0694
Copy link
Member

Description of the new feature/enhancement

On my machine, I have set the sleep time to 15 minutes. Sometimes (eg. when running long builds) I would just step away from it and let it work, but then come back with it being on standby and with the work just paused, which is pretty annoying. It would be nice if Terminal had an option to make it automatically prevent the machine going to sleep if there's some operation running in any tabs. This is pretty common for other applications/websites as well (eg. if you have Spotify playing music in Edge, your computer won't go to sleep).

Note

Tried searching for a similar issue and couldn't find one, so hopefully this is not a duplicate.

Proposed technical implementation details

PowerToys is already doing this in their "awake" feature, we could probably just do the same here?
Ie. SetThreadExecutionState?

@Sergio0694 Sergio0694 added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Nov 25, 2023
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Nov 25, 2023
@zadjii-msft
Copy link
Member

I... don't hate this. But knowing when to do this would be tricky. We wouldn't necessarily want to always prevent sleep if the Terminal is running - we'd probably want to only do that if there's a child process running. That of course gets into weird edge cases - just running ssh from a shell (or heck, just cmd.exe from PowerShell) would then satisfy the heuristic here and would keep the PC alive.

Terminal doesn't currently track the tree of processes. We'll need to do that for #6549 though

@Sergio0694
Copy link
Member Author

To give a real world use case scenario, I hit this when building https://github.com/microsoft/CsWinRT locally, which takes like half an hour. Started ./build.cmd, stepped away, came back after an hour and the PC had just gone to sleep after 10 minutes 🤦‍♂️

@DHowett
Copy link
Member

DHowett commented Nov 29, 2023

This may be more suitable as a tool outside of Terminal, FWIW. I'm imagining something like macOS' caffeinate. You can caffeinate, and it will keep the machine awake until you press Ctrl+C, or you can caffeinate foo and it will keep the machine awake until foo exits.

@zadjii-msft
Copy link
Member

that's actually really clever

@Sergio0694
Copy link
Member Author

Would it perhaps make sense to have it just built-in into Terminal, so you can opt-in on a per-command basis?

@zadjii-msft
Copy link
Member

have it just built-in into Terminal ... ?

Eh, honestly, in the name of trying to keep things as minimal as possible, probably not. However, there is PowerToys.Awake, but I cannot for the life of me figure out how to get the CLI to work

@crutkas help me out

@zadjii-msft zadjii-msft added the Resolution-External For issues that are outside this codebase label Dec 5, 2023
@crutkas
Copy link
Member

crutkas commented Dec 7, 2023

as of now, you'd need to turn off awake PowerToys can do it all via CLI but you'll want to turn it off inside PowerToys. We're working on improving this so the two can work side by side.

I grabbed the PID for Notepad in this example

PS C:\Users\crutkas> cd C:\Users\crutkas\AppData\Local\PowerToys
PS C:\Users\crutkas\AppData\Local\PowerToys> .\PowerToys.Awake.exe --pid 24384 --display-on true
image

soon as i closed out notepad, screen would turn off.

Good feedback for better documentation and see if we can't do CLI + PT open at same time work.

@crutkas
Copy link
Member

crutkas commented Dec 7, 2023

@zadjii-msft i believe we can close this out as PT would be the team for this

@DHowett
Copy link
Member

DHowett commented Dec 7, 2023

Thanks @crutkas!

@Sergio0694, if PowerToys Awake (CLI) doesn't quite fit your needs... we can all work together to make sure something does. 😄

@DHowett DHowett closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-External For issues that are outside this codebase
Projects
None yet
Development

No branches or pull requests

4 participants