Skip to content

Comment on Auto Dark Mode for Windows

Comments

Years ago, I wrote a very stripped-down version in a few lines of PowerShell. I'll upload it when I get home.

I did the same just a few days ago based on webcam, 26 lines of PowerShell.

See https://gist.github.com/lostmsu/cde4a8578d8e0ea1182f579f44bd...

my minimal powershell code

    $old = -1
    while ($true) {
        $d = Get-Date
        $hour = $d.Hour
        if ($hour -ge 6 -and $hour -lt 19) {
            $light = 1
        } else {
            $light = 0
        }
        if ($old -ne $light) {
            Set-ItemProperty HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize AppsUseLightTheme $light
            $old = $light
            echo $light $d
        }
        sleep -Seconds 2
    }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.