Switching the Windows Theme With the Sun in My G-Helper Fork

Dec 3, 2026 min read

I use G-Helper every day on my ASUS laptop. Windows doesn’t have a way to switch between light and dark theme on its own, and I was tired of doing it by hand every evening. Yes, I know there’s Power Toys and yes, I’ve tried it extensively. TLDR: I can’t use just the light switch feature, it has many interesting ones, and I usually enable a lot of them which results in battery drain.

Light Switch also runs as its own service and checks the time every 60 seconds. It does that because it has nothing better to hook into. G-Helper does: it’s already running in my tray all the time, and it already knows when the laptop wakes up, when I switch sessions and when the clock changes. So my version doesn’t poll at all. It works out when the sun will next cross the threshold, sets one timer for that, and ends up checking four or five times a day. No extra process, no extra dependency.

PowerToys also shipped Light Switch turned on by default in 0.95 and had to walk it back after people saw their theme flip “randomly”. I didn’t want anything changing my theme without me expecting it.

Before this I was using two PowerShell scripts and a Task Scheduler job. One switched the theme at logon and at two scheduled times. The other called a sunrise/sunset API once a week for my location, added an hour on each side, and rewrote the task’s triggers. It worked, but I couldn’t flip the theme with one key, and that’s what I actually wanted most. G-Helper already handles my laptop’s keys, so that’s where it went.

So I forked G-Helper and added it. I built it for myself, but the fork is public here if anyone wants it.

What it does

You can switch the theme three ways. Click the sun/moon icon next to Visual Mode, bind it to a key (M1–M4, Fn+C, or any other bindable key), or turn on the schedule and let it follow the sun. Right-clicking the icon opens the schedule settings.

Left click to toggle, right click for settings

Customizing M1-M4 keys to Toggle Themes

For the schedule, you set your latitude, longitude, and how high the sun needs to be for it to count as daytime. The default is 10°, so it switches to light a bit after sunrise and back to dark a bit before sunset. The dialog shows the times your settings work out to, so if you typed a wrong coordinate you’ll see it before saving.

A toggle to enable or disable the schedule, and setup for location and sun elevation

I didn’t want it calling any location service, so the sun’s position is calculated locally with NOAA’s solar position formula. It works offline. The coordinates start from your Windows time zone and you can change them. Near the poles the sun can stay above or below the threshold all day, and in that case it just tells you instead of making up a time.

It checks the schedule on startup, when you switch sessions, when the laptop wakes up, and when the clock changes. If you flip the theme by hand, it leaves your choice alone until the schedule disagrees again, so switching to dark at night doesn’t get undone the next time it checks.

Bugs I ran into

The first version worked, but using it for a few days showed some problems.

Pressing the toggle quickly a few times could end up on the wrong theme. Each press started its own task, and they all waited on a lock. .NET’s Monitor doesn’t guarantee order, so they could finish in a different order than I pressed them. I changed it to one worker that only applies the latest request. Now a burst of presses does one update and lands where I left it.

Sometimes a press did nothing at all. G-Helper cached the theme it last set, so if the theme was changed from Windows settings, the next press would “set” the theme that was already active. Now the toggle reads the pending change if there is one, and the registry if not.

Wake-up, session and clock events come in on a different thread than the UI, and that thread was starting and stopping a UI timer. That’s not allowed in WinForms. Those events now hand off to the UI thread first.

Keeping the fork up to date

The other reason I hadn’t forked before is that forks fall behind. G-Helper gets updates all the time, and I didn’t want to merge them by hand. So I set up GitHub Actions to merge upstream into my fork every day, and to build a release only when upstream publishes a stable one.

Fork releases are versioned as the upstream version plus a fork number. For example, 0.288.26 is upstream 0.288 with my changes. Upstream only uses two numbers, so my versions never clash with theirs. I also pointed the auto-update at my fork, so updates include my changes.

My notes are in a separate README.fork.md. Upstream edits their README a lot, and keeping mine identical to theirs means one less file to conflict on.