Skip to content

jthorborg/sleepydisk

Repository files navigation

sleepydisk

Windows tray application that spins down a specific hard drive after a configurable idle period. The drive wakes automatically when next accessed — Windows handles that transparently.

Useful for drives that ignore Windows' own power management, or where Windows erroneously keeps them spinning despite no user activity.

While researched and prototyped manually, this software is entirely vibecoded. It works, but use at your own risk.

sd_asleep

Dependencies

smartctl must be available in PATH or placed next to sleepydisk.exe. It is freely redistributable under the GPL.

Tool Source Required Purpose
smartctl smartmontools Yes Detect standby state; send spin-down command
handle.exe Sysinternals Handle No Identify which processes are holding files open on the drive

handle.exe is optional. If it is not found in PATH or next to sleepydisk.exe, open file checking is automatically disabled and the tray menu will say so. The drive will still be spun down when idle — it just won't tell you what was holding it open. This is equivalent to passing --no-handle-check.

sleepydisk requires administrator privileges (smartctl needs them). It will self-elevate via UAC on launch if not already elevated.

Usage

sleepydisk.exe --drive <identifier> --timeout <duration> [--poll <seconds>] [--no-handle-check]

Arguments

Argument Required Description
--drive <identifier> Yes Model name substring or serial number of the target drive. Case-insensitive.
--timeout <duration> Yes Idle period before spin-down. Accepts 10m, 1h, or a plain number (interpreted as minutes).
--poll <duration> No How often to sample disk activity. Default: 10s.
--no-handle-check No Skip the handle.exe check entirely. When the timeout elapses and I/O is zero, spin down immediately without checking for open files.

Examples

sleepydisk.exe --drive "WD Red" --timeout 10m
sleepydisk.exe --drive "WD-RD3W354G" --timeout 30m --poll 30s
sleepydisk.exe --drive "WD80EFPX" --timeout 1h --no-handle-check

The identifier is matched against both the drive model and serial number as reported by smartctl -i. A substring match is sufficient — you don't need the full string.

To find the right identifier, run:

smartctl --scan
smartctl -i /dev/sda

Tray icon

The application lives in the system tray. Right-clicking shows:

  • Current drive state and idle time, or the list of processes blocking sleep
  • Force Sleep Now — sends the standby command immediately
  • Exit

Hovering the tray icon shows a short status summary.

sd_blocked

How it works

Every poll cycle (default 10 seconds):

  1. Read Windows I/O performance counter — zero cost, no device communication, will not wake a sleeping drive. If transfers are nonzero, the drive is active; reset the idle timer and wait.
  2. If no transfers and standby already confirmed — stay in standby without invoking smartctl. A waking drive would register I/O for its spinup, so zero transfers is sufficient proof it hasn't woken.
  3. If no transfers and standby not yet confirmed — call smartctl -n standby to check without waking the drive. If in standby, record the time and switch to a slower poll interval.
  4. If awake and idle longer than --timeout — if handle.exe is available and --no-handle-check is not set, list open file handles on the drive's volumes. Common background OS processes are filtered out. If anything remains, report it in the tray and wait.
  5. If nothing is holding the drive open — call smartctl -s standby,now to spin it down.

While the drive is in standby, the poll interval automatically extends to max(timeout, 60s) to avoid unnecessary subprocess overhead.

Running multiple drives

Run one instance of sleepydisk per drive:

sleepydisk.exe --drive "WD Red" --timeout 10m
sleepydisk.exe --drive "Seagate" --timeout 20m

Auto-start with Windows

Task Scheduler is required to auto-start an elevated process without a UAC prompt on every boot. Registry Run keys and the Startup folder do not support elevation.

Via command line (run once from an elevated prompt):

schtasks /create ^
  /tn "sleepydisk-WDRed" ^
  /tr "\"C:\Tools\sleepydisk.exe\" --drive \"WD Red\" --timeout 10m" ^
  /sc onlogon ^
  /rl highest ^
  /f

Via Task Scheduler GUI:

  1. Open Task Scheduler → Create Task
  2. General tab → check Run with highest privileges
  3. Triggers tab → New → At log on → your user account
  4. Actions tab → New → program: path to sleepydisk.exe, arguments: your flags
  5. Conditions tab → uncheck Start only if on AC power if needed

Requirements

The .NET 8 Desktop Runtime must be installed on the target machine. It is included in most Windows 11 installations; if absent, the executable will prompt with a download link on first launch.

Building from source

Requires the .NET 8 SDK.

dotnet build

To produce a single-file release executable (~500 KB):

dotnet publish -r win-x64 --no-self-contained -p:PublishSingleFile=true

Output: bin\Release\net8.0-windows\win-x64\publish\sleepydisk.exe

About

Windows tray / startup utility that spins harddisk drives down after inactivity

Resources

License

Stars

Watchers

Forks

Contributors

Languages