DEV Community

Humberto Schoenwald
Humberto Schoenwald

Posted on

A .NET 11 Windows theme switcher (Win32 interop & local solar math)

I just built an app and I want GitHub stars. If it works for your personal use, perfect.

Now, for the developers (which is probably all of you, haha):

I built this app for fun and because auto dark-mode is genuinely a feature I miss from macOS when I'm using Windows. I made it extremely lightweight—it currently uses around 34MB active and 8MB idle.

Here is a fun fact about the development: I initially built the first version using WPF. It looked beautiful, but it was consuming around 130MB of RAM just sitting there doing nothing. I knew people were going to hate that, and I knew I could do better. I scrapped that UI layer and rewrote it using raw Win32. Even though I honestly wouldn't care if it consumed 300MB of RAM on my own machine, rewriting it to be that light became a fun optimization challenge.

Another fun fact regarding the repository quality: I manually whitelist every single Spanish word used in the LÉEME.md (Spanish README). Instead of "contaminando" my environment with standard language extensions, I maintain dedicated .txt dictionaries inside a .cspell directory. This ensures that only intentional, approved terms are permitted and prevents English typos from being masked as valid Spanish words during the CI process.

I focused on keeping it private and secure, obviously, without storing coordinates in plain text by using Windows DPAPI. (This doesn't protect your coordinates against a massive virus taking over your PC, but it keeps them properly encrypted locally).

Technical implementation facts:

  • Math over APIs: It calculates the solar schedule locally using the Julian day and observer coordinates instead of pinging external weather APIs. It natively handles mathematical edge cases like Polar Nights and Midnight Sun.
  • Native Application Lifecycle: I'm bypassing heavy frameworks. The app runs on a sealed NativeApplication class that handles single-instance locking via Mutex, manual ServiceProvider validation, and a pure native Win32 message loop via NativeInterop.RunMessageLoop().
  • Zero UI Frameworks: Everything is built using raw Win32 interop via LibraryImport. To make the theme transition seamless without requiring app restarts or causing screen flickers, it hooks into undocumented uxtheme.dll exports (#104 and #136).
  • High-Quality Tooling: I set up a strict GitHub Actions pipeline enforcing Conventional Commits via commitlint, spell-checking via cspell (using my custom local dictionaries), and automatic CalVer releases.

My purpose in uploading this: to get stars to build reputation and make money from this (using it as a portfolio), besides validating the time I invested in it haha.

If anyone finds the technical stuff useful to copy, go ahead. Here is what you can learn or reuse from the repo:

  • How to structure a Modular Monolith with Vertical Slices.
  • Implementing zero-framework native Win32 UIs in C#.
  • Replacing exceptions with the functional Result<T> pattern.

Bonus: I also included my entire .cursor/rules directory and AGENTS.md. These are file-scoped rules that prevent AI agents (like Cursor) from hallucinating and keep them strictly following C# 15 / .NET 11 standards.

🔗 auto-theme-solar-engine on GitHub

Top comments (0)