Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

WSLKeeper

WSLKeeper is a lightweight Windows tray app for keeping selected WSL2 distributions alive.

It provides a compact per-distro toggle UI and uses:

wsl -d <DistroName>-e sleep infinity

to prevent idle shutdown for workloads that need long-lived availability (for example SSH/services running inside WSL).


Features

  • Tiny tray-first UI (double-click tray icon to reopen)
  • Auto-discovery of distros from wsl -l -v
  • Per-distro keepalive toggle
  • Running-state indicator (Running / Stopped)
  • Auto-refresh loop
  • Cleanup on app exit

How it works

  1. WSLKeeper reads distro status using wsl -l -v.
  2. When you enable keepalive for a distro, it launches a detached wsl.exe keepalive process.
  3. When you disable keepalive, it attempts to stop keepalive for that distro.
  4. On application exit, keepalive cleanup is executed.

Note: Keepalive intent (toggle state) and runtime state (distro running/stopped) are intentionally handled as separate signals.


Requirements

  • Windows 10/11 with WSL2 installed
  • At least one WSL distro

Build

This repository can be built from Linux/WSL using .NET SDK 8.

1) Install .NET SDK (if needed)

curl -fsSL https://dot.net/v1/dotnet-install.sh -o dotnet-install.sh
bash dotnet-install.sh --channel 8.0 --install-dir ~/.dotnet

2) Publish Windows executable

~/.dotnet/dotnet publish \
/home/kyaky/projects/WSLKeeper/src/WSLKeeper/WSLKeeper.csproj \
-c Release \
-r win-x64 \
--self-contained true \
-p:PublishSingleFile=true \
-p:IncludeNativeLibrariesForSelfExtract=true \
-o /home/kyaky/projects/WSLKeeper/dist/win-x64

Build output:

  • dist/win-x64/WSLKeeper.exe

Run

Launch WSLKeeper.exe on Windows.

  • Minimize sends it to tray
  • Double-click tray icon to reopen

Troubleshooting

Toggle enabled but distro still Stopped

Validate manually in PowerShell:

wsl -d <DistroName>-e sleep infinity

If this command does not stay active, investigate WSL/distro environment first.

List active keepalive processes

Get-CimInstance Win32_Process |Where-Object { $_.Name-eq"wsl.exe"-and$_.CommandLine-match"sleep\s+infinity" } |Select-Object ProcessId, CommandLine

Force-stop all keepalive processes

Get-CimInstance Win32_Process |Where-Object { $_.Name-eq"wsl.exe"-and$_.CommandLine-match"sleep\s+infinity" } |ForEach-Object { Stop-Process-Id $_.ProcessId-Force }

Project status

Stable for practical local use. Ongoing improvements can focus on stricter per-distro process tracking and additional UI polish.

About

WSLKeeper is a lightweight Windows tray app that manages WSL2 distro keep-alive with one-click toggles, preventing idle shutdown by running sleep infinity per distro.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages