Automatic Windows light/dark mode switcher based on sunrise and sunset times. Runs as a lightweight system tray app.
- Switches Windows app and system theme at sunrise (light) and sunset (dark)
- System tray icon with context menu for manual override
- Configurable location and time offsets
- ~600KB single binary, no background service required
Requires Rust 1.85+ (2024 edition).
cargo build --release
The binary is at target\release\daylight.exe. Copy it wherever you like.
Right-click the tray icon and check Start with Windows. This adds a registry entry to HKCU\...\Run so daylight launches at login — no shortcuts or Task Scheduler needed.
On first run, daylight creates a config file at:
%APPDATA%\daylight\config.toml
Edit it with your location coordinates:
# daylight configuration
# Edit latitude/longitude for your location.
# Offsets are in minutes (positive = later, negative = earlier).
latitude = 40.7128
longitude = -74.0060
# sunrise_offset = 0
# sunset_offset = 0| Key | Type | Default | Description |
|---|---|---|---|
latitude |
float | 40.7128 |
Your latitude (-90 to 90) |
longitude |
float | -74.0060 |
Your longitude (-180 to 180) |
sunrise_offset |
integer | 0 |
Minutes to shift sunrise (positive = switch later) |
sunset_offset |
integer | 0 |
Minutes to shift sunset (positive = switch later) |
Search "[your city] coordinates" or use latlong.net. A few examples:
| City | Latitude | Longitude |
|---|---|---|
| New York | 40.7128 | -74.0060 |
| London | 51.5074 | -0.1278 |
| Tokyo | 35.6762 | 139.6503 |
| Sydney | -33.8688 | 151.2093 |
Changes take effect after restarting daylight.
Run daylight.exe. A tray icon appears:
- Yellow circle = light mode active
- Blue circle = dark mode active
Right-click the tray icon for the context menu:
| Item | Action |
|---|---|
| Mode: Light/Dark | Shows current mode (read-only) |
| Switch to Dark/Light | Manually toggle theme (sets manual override) |
| Automatic | Checked when in auto mode; click to return to auto after a manual override |
| Start with Windows | Toggle auto-start at login (writes to registry Run key) |
| Quit | Exit daylight |
Hover over the tray icon to see the next scheduled switch time.
Clicking "Switch to Dark/Light" activates a manual override. The app stays in that mode until you either:
- Re-select Automatic from the menu
- Wait until midnight (overrides clear automatically)
- Reads your latitude/longitude from the config file
- Calculates today's sunrise and sunset times using the sunrise equation
- Sets a Win32 timer to fire at the next sunrise or sunset
- When the timer fires, writes
AppsUseLightThemeandSystemUsesLightThemeto the registry and broadcastsWM_SETTINGCHANGEso all apps update immediately - A housekeeping timer runs every 60 seconds to handle date rollover and edge cases