Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

daylight

Automatic Windows light/dark mode switcher based on sunrise and sunset times. Runs as a lightweight system tray app.

Features

  • 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

Installation

From source

Requires Rust 1.85+ (2024 edition).

cargo build --release

The binary is at target\release\daylight.exe. Copy it wherever you like.

Run at startup (optional)

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.

Configuration

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

Options

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)

Finding your coordinates

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.

Usage

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.

Manual override

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)

How it works

  1. Reads your latitude/longitude from the config file
  2. Calculates today's sunrise and sunset times using the sunrise equation
  3. Sets a Win32 timer to fire at the next sunrise or sunset
  4. When the timer fires, writes AppsUseLightTheme and SystemUsesLightTheme to the registry and broadcasts WM_SETTINGCHANGE so all apps update immediately
  5. A housekeeping timer runs every 60 seconds to handle date rollover and edge cases

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages