Skip to content

Automatically set Windows to Light or Dark mode based on sunrise or sunsite

License

Notifications You must be signed in to change notification settings

EBOOZ/Set-WindowsColorMode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

I am a fan of the light mode in Windows 11. However, it can be a bit too much when I'm working in our home office and when it's dark outside. I'm really missing a feature that switches from light to darkmode based on the time of the day, and vice versa. That is why I developed this script which is running as a service, and checks every 15 minutes if it's either sunrise or sunsite time and changes the color mode accordingly.

Important

Currently the script only works with an API from Weerlive. I'm planning to add support for Home Assistant sensors.

Requirements

  • Download the files from this repository and save them to C:\Scripts\Set-WindowsColorMode
  • (Optional) Create an account and request an API key at Weerlive
    • Edit the Settings.ps1 file and:
      • Replace <API KEY> with the API you received
      • Replace <CITY> with the name of the city where you are based
      • Optionally change different wallpapers for light and dark modes
    • Save the Settings.ps1 file
  • Start a elevated PowerShell prompt, browse to the folder you have stored the scripts, and run the following command:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -ErrorAction SilentlyContinue
Unblock-File .\Settings.ps1
Unblock-File .\Set-WindowsColorMode.ps1
Start-Process -FilePath .\nssm.exe -ArgumentList 'install "Windows Color Mode monitoring" "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-command "& { . C:\Scripts\Set-WindowsColorMode\Set-WindowsColorMode.ps1 }"" ' -NoNewWindow -Wait
Start-Service -Name "Windows Color Mode monitoring"

After completing the steps below, confirm if the color mode is updated as expected when it's either getting light or dark outside.

About

Automatically set Windows to Light or Dark mode based on sunrise or sunsite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published