Last active
April 20, 2024 17:39
-
-
Save hasparus/4b497d225ce126deed44168299252978 to your computer and use it in GitHub Desktop.
A PowerShell script setting light mode during the day and dark mode after 18:30.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set your triggers to 06:00, log in, and 18:30. | |
# Set this to false if you like light Windows UI. | |
# Personally, I'm conflicted so I change it back and forth every few months. | |
$SYSTEM_ALWAYS_DARK = $TRUE | |
$lightTheme = @{ AppsUseLightTheme = 1; SystemUsesLightTheme = 1 } | |
$darkTheme = @{ AppsUseLightTheme = 0; SystemUsesLightTheme = 0 } | |
# We set light mode between 06:00 and 18:30. | |
$time = Get-Date -Format 'HH:mm' | |
$isDay = $time -ge '06:00' -and $time -le '18:30' | |
if ($isDay) { | |
$settings = $lightTheme | |
} else { | |
$settings = $darkTheme | |
} | |
if ($SYSTEM_ALWAYS_DARK) { | |
$settings.SystemUsesLightTheme = 0 | |
} | |
foreach ($key in $settings.Keys) { | |
$value = $settings[$key] | |
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name $key -Value $value | |
} |
Author
hasparus
commented
Oct 31, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment