Skip to main content
  1. Writing/

A New PowerToys Awake Is Out

·479 words
Table of Contents

The new PowerToys are out (we’re at version 0.70.0) and with it comes a new version of Awake, the caffeinate tool that folks are used to on a Mac, brought to life on Windows. The release tag for this version is ATRIOX_04132023.

This update is, in large, a maintenance one - I optimized some code path and simplified internally how Windows APIs are called, which is mostly entirely transparent to customers using the tool.

With all the changes, there are two improvements I want to call out that should really make the overall quality of the tool better.

First, I completely removed the code that deals with spinning up new threads when state changes. That is, you might’ve noticed that right after an Awake cycle completes, running powercfg /requests would still show that PowerToys.Awake.exe was “holding” the computer power settings for anywhere between 5 seconds to a minute. This was not necessarily resulting in a horrible experience, as the time is close to negligible, but it is going against the promise to the end user that the cycle will stop when you tell it to stop. This behavior was caused by the fact that for each state change in Awake a new thread would be spun up that would have a SetThreadExecutionState call done within it that would request a specific execution state combination. However, when the thread would finish, the tool would still need to wait for the thread cleanup that is a bit variable in terms of time. Orphaned threads sometimes resulted in unexpected behaviors, so I decided to do away with this approach entirely. Instead, now you have a single thread that observes state change requests and adjusts its execution state accordingly, resulting in much smoother transitions from one state to another.

Second, a completely new capability was added, that now allows you to keep your computer awake until a specified date and time. Previously, you could ask to keep the computer awake indefinitely or for a time interval (e.g., two hours and fifteen minutes). Now you can give Awake an end date and time, and it will maintain the state until then.

GIF showing selection of expiration time in the new version of Awake

The functionality is also available from the command line for those adventurous folks who want to use Awake in scripts:

PowerToys.Awake.exe --expire-at="4/13/2023 17:00:00"

You can read more about all available terminal options in the official tool documentation.

What’s next #

Most of the future-looking stuff for Awake is captured in the form of GitHub issues. If you have any bug reports, suggestions, or question, the official PowerToys repository is the place to submit those. Outside of those, one of the areas I am actively working is ditching System.Windows.Forms - a massive dependency that balloons the size of the tool distribution that I am trying to trim (it’s really only used for tray icon management). More on that in one of the future releases!