Skip to content

Repository files navigation

Awake

Standalone system tray utility to prevent Windows from sleeping.

A lightweight .NET 9 Windows tray utility inspired by PowerToys Awake. Uses Bootstrap cup-hot / cup-hot-fill icons for active/off tray state.

Features

  • Keep awake indefinitely — prevents system sleep
  • Keep screen on — optional display prevention checkbox
  • Start at login — toggles HKCU registry Run key
  • System tray — left-click or right-click context menu, state indicators, Explorer restart resilience
  • Single instance — duplicate launches show a warning
  • Single-file publish — framework-dependent Awake.exe with app assemblies bundled

Building

Prerequisites

  • .NET 9 SDK to build
  • .NET 9 Desktop Runtime on machines that run the framework-dependent publish
  • Windows 10/11 for runtime tray behavior

Build

dotnet build

Test

dotnet run --project Awake.Tests/Awake.Tests.csproj

Publish

dotnet publish Awake.csproj -c Release -r win-x64 --self-contained false

The published executable is written to:

bin/Release/net9.0-windows/win-x64/publish/Awake.exe

Release publish is single-file and framework-dependent. The target machine still needs the .NET 9 Desktop Runtime installed.

Usage

Launch Awake.exe. It sits in the system tray. Left-click or right-click the icon for the menu.

ActionDescription
Keep awake indefinitelyToggle system sleep prevention
Keep screen onAlso prevent display from turning off (disabled when awake is off)
Start at loginAuto-start with Windows via HKCU\...\Run\Awake
ExitCleanly stops sleep prevention and exits

Architecture

App/
├── Program.cs Entry, single-instance guard, startup diagnostics
├── TrayApplicationContext.cs WinForms NotifyIcon, menu, hidden tray host window
├── WindowsPowerStateApplier.cs SetThreadExecutionState adapter
├── WindowsStartupRegistry.cs HKCU Run key adapter
├── ProcessExecutablePathProvider.cs
├── MutexSingleInstanceLock.cs
└── AwakeIcons.cs Embedded active/off icon loading
Awake.Core/
├── TrayShellController.cs Tray state, menu projection, command handling
├── StartupManager.cs Startup registry boundary
├── SingleInstanceGuard.cs
├── StartupDiagnostics.cs
└── AwakeIconIdentity.cs
Awake.Tests/
└── Program.cs Lightweight behavior test runner

Icons

Icon source SVGs are checked in from Bootstrap Icons:

  • Assets/bootstrap-cup-hot.svg
  • Assets/bootstrap-cup-hot-fill.svg

Generated ICOs are multi-size Windows icon files:

  • Assets/awake-off.ico
  • Assets/awake-on.ico

To regenerate the ICOs from the SVG sources:

tmpdir=$(mktemp -d)
npm install --silent --prefix "$tmpdir" sharp
NODE_PATH="$tmpdir/node_modules" node tools/render-bootstrap-icons.mjs
rm -rf "$tmpdir"

Manual Windows Smoke Test

Before release, verify on Windows 10/11:

  • Start Awake.exe; it appears in the notification area and no main window/taskbar window appears.
  • Left-click and right-click both open the same tray menu.
  • The menu spacing, typography, separators, checkmarks, disabled Keep screen on state, and active/off icons look clean at normal DPI.
  • Toggle Keep awake indefinitely; the tray icon and tooltip change to active.
  • Toggle Keep screen on while Awake is active; then turn Awake off and confirm screen-on clears and disables.
  • Toggle Start at login and confirm HKCU\Software\Microsoft\Windows\CurrentVersion\Run\Awake is created/removed.
  • Launch a second copy and confirm it shows the Awake is already running. warning without disrupting the first process.
  • Restart Explorer and confirm the tray icon reappears and still opens the menu.
  • Choose Exit and confirm the tray icon disappears and power-prevention state clears.

You can record the visual and lifecycle checks with:

powershell -ExecutionPolicy Bypass -File tools\windows-smoke-test.ps1

The script writes records\topics\2026-06-13-dotnet9-tray-rewrite\manual-windows-smoke.txt.

License

MIT

About

Standalone system tray utility to prevent Windows from sleeping.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages