How can I enable sleep when idle, but only outside of work hours?

0

I want my laptop to sleep after an hour of being idle (and plugged in), but ONLY outside of work hours (eg: 8am-5pm Mon-Fri). I'm not trying to disable sleep entirely during work hours, it just has to be done manually (unless on battery).

What are the best ways to achieve this?

Some ideas I've had:

  • Set the Power Plan settings to never sleep, and use the task scheduler to run a command to tell the PC to sleep under certain conditions. I'm not sure though if the logic can be set up in a way that disables the condition during a time window and checks for inactivity otherwise.
  • Use the task scheduler to disable sleep-on-idle timer as part of the power plan at 8am, then set the time to 1 hour at 6pm. This solution would need to leave the On-battery sleep timer active at all times.

Windows power plan idea

I'm specifically using Windows 10 on a laptop, but an ideal solution would work for other configurations as well.

Bort

Posted 2019-10-14T18:27:42.673

Reputation: 914

Answers

0

Windows Sleep (Windows 7 and above) is designed to operate after a specific time interval. For my laptop, I just close the lid when needed. For a desktop, it seems as easy to suspend when done or (as you are suggesting) make a task to run at 6:00 pm (say) each day to run Power Manager which will then Sleep after an interval.

Another thought - my desktop now has an SSD drive and I just let it run. Monitor turns off after 20 minutes of non-use but the machine does not suspend. No real need.

John

Posted 2019-10-14T18:27:42.673

Reputation: 5 395

Thanks, but that doesn't really answer the question. If you must know, the computer fans are annoying, there is significant power draw, and in turn heat. The system still ages, with additional dust collection. It may also play sounds late at night. – Bort – 2019-10-14T19:11:19.190

There is no way (I have ever seen) to make Windows suspend at a specific point, only after an interval of time. So Task Manager at at specific time is your only real option – John – 2019-10-14T19:13:26.583

I don't want it to sleep at a "specific point", I want it to sleep after an interval of time. Please read the question again. – Bort – 2019-10-14T19:14:52.970

How would it work if a task runs at 6pm? For example, say I want it to sleep after 1 hour of inactivity. If I'm idle from 7pm to 7:30, then idle again at 9pm, does it sleep at 10pm? How do I make it stop trying after 8am the next day? – Bort – 2019-10-14T19:15:57.913

"only outside of working hours" is a specific time so that is what I was suggesting – John – 2019-10-14T19:16:17.647

"I want my PC to sleep after an hour of being idle, but ONLY outside of work hours (eg: 8am-5pm)." By that I mean that I want it to sleep after I'm idle for X minutes, but not during work hours. I'll edit the question in case it was confusing. – Bort – 2019-10-14T19:17:30.700

powercfg is a command line approach to run power options by command – John – 2019-10-14T19:18:45.343

You have made it a bit difficult by saying "don't suspend" in working hours, only after working hours. So the idea of task manager to identify working hours is about all there is – John – 2019-10-14T19:23:18.110

I think you mean "task scheduler"? – Bort – 2019-10-14T19:35:37.060

My error above. I meant Task Scheduler - not Manager. Sorry about the typo – John – 2019-10-14T19:36:27.473

0

You can use the windows task scheduler to run a script after the PC becomes idle and limit it to a certain time frame under trigger.

enter image description here

If you want to make sure it's idle for a specific amount of time you can use the conditions tab (see here)

enter image description here

In my script I use psshutdown with the following command psshutdown -d -t 0 to put the PC to sleep.

Albin

Posted 2019-10-14T18:27:42.673

Reputation: 3 983

At first I didn't think that would work because Wait for idle for: is how long it will wait for the idle duration to become true, and the maximum duration in the drop down list is only 2 hours. But it needs to wait all the way until the next work shift, which could be 2 days and 15 hours away (63 hours total) if it starts waiting at 5pm on a Friday. That being said, I tried manually typing "15 hours" in to the drop down and it seems to accept that. So I think it may work if I make two tasks: One for weekdays (15 hour wait) and another task for the weekend (63 hour wait). – Bort – 2019-10-15T01:13:10.217

@Bort right, I didn't consider that the dropdown was limited two hours. let me know if it worked. – Albin – 2019-10-15T06:59:35.977