gabrielkheisa 56503c065d first
2025-04-19 20:05:02 +07:00

3.1 KiB

Auto Theme + Wallpaper Switcher (Windows)

This is a lightweight Windows tray app that automatically switches between light and dark mode based on the time of day (6 AM to 6 PM), and optionally changes your desktop wallpaper. It also silently restarts explorer.exe after theme changes to force a full UI refresh (taskbar, Start menu, etc.).

cover

Runs quietly in the background with a tray icon and auto-starts on login (via shell:startup).


Features

  • Automatically switches between light and dark mode
  • Optionally changes wallpaper to match the theme
  • Gracefully skips if wallpaper is missing (no crashes)
  • Runs silently with a tray icon and no console window
  • Uses native Windows APIs (registry + wallpaper)
  • Automatically restarts explorer.exe for full theme refresh

Setup Instructions

Place these files in the same directory:

themechanger.exe       ← compiled binary  
icon.ico               ← tray icon (required)  
light.jpg/png/bmp/...  ← optional day wallpaper  
dark.jpg/png/bmp/...   ← optional night wallpaper  

Supported image formats: .jpg, .jpeg, .png, .bmp, .webp

The app will look for light.* and dark.* in its own folder. If no image is found, it simply skips the wallpaper change.


Auto-Start on Login

To launch the app automatically when you log in:

  1. Press Win + R
  2. Type: shell:startup and press Enter
  3. Create a shortcut to themechanger.exe:
    • Right-click on themechanger.exe.
    • Select "Create shortcut".
  4. Move the shortcut you just created into the Startup folder. The Startup folder is the one that opened in step 2.

Done! It will now auto-start silently every time.

No need to edit the registry or install anything!


Build It Yourself

If you'd like to compile from source:

1. Install Go

https://go.dev/dl

2. Initialize your Go module

go mod init themechanger
go mod tidy

3. Build the executable

go build -ldflags="-H windowsgui" -o themechanger.exe

This produces a GUI app (no console window).


Technical Details

  • Uses Go and the systray library for tray UI
  • Theme switching via registry keys:
    • AppsUseLightTheme
    • SystemUsesLightTheme
  • Wallpaper changes with SystemParametersInfoW API
  • Explorer restart via:
    taskkill /f /im explorer.exe && start explorer.exe
    

🖼 Tray Preview

You must provide your own icon.ico in the same folder — this will be used as the tray icon.

Tip: You can create .ico files from PNGs using online converters like icoconvert.com


Notes

  • You can manually quit the app from the tray menu
  • Time check runs every 60 seconds
  • Changing the clock or timezone will trigger a switch automatically
  • No admin rights needed

Optional Ideas

  • Add GUI to configure start/stop time
  • Manual override options in tray menu
  • Geo-based sunrise/sunset switching

License

MIT — free for personal and commercial use.


Made with Go, Windows quirks, and coffee