Skip to content

Repository files navigation

PowerShell-Lumos

Build Status coverage

A PowerShell module for switching Windows 10/11 and macOS between light and dark themes depending on whether it is day or night.

Warning

Breaking change for Windows users: Running Invoke-Lumos with no switches used to automatically pick Dark/Light based on your location and time of day on Windows. It now toggles to the opposite of whatever theme is currently active instead (matching the existing macOS behavior). Use the new -Auto switch to get the old automatic behavior back.

If you previously ran Register-LumosScheduledTask, re-run it to re-create the scheduled task - the existing task was created using the old default behavior and won't pick up -Auto on its own.

Windows:

macOS:

Invoke-Lumos

This module is published in the PowerShell Gallery, so can be installed via:

Install-Module Lumos

Usage

You can manually trigger Lumos as follows:

Invoke-Lumos

On both Windows and macOS, using Invoke-Lumos with no switches will switch the theme to its alternate, i.e. if it's Light it will switch to Dark and if Dark switch to Light.

You can also simply use the alias Lumos.

You can explicitly specify whether you want the Dark or Light modes on both Windows 10/11 and macOS with the following switches:

Invoke-Lumos -Dark

Invoke-Lumos -Light

Or you can have Lumos decide automatically, based on your location (determined from your public IP address) and whether it is currently before or after sunrise/sunset there:

Invoke-Lumos -Auto

If the sun is down, the theme will be set to dark. If the sun is up, the theme will be set to light. -Auto works the same way on both Windows and macOS.

By default the cmdlet will change both the System and Application themes, but on Windows 10/11 if you'd like to just change one of these you can exclude the other by using these switches:

Invoke-Lumos -Dark -ExcludeSystem

Invoke-Lumos -Light -ExcludeApps

These switches are not available on macOS.

If you'd like your wallpaper to change with the theme (on Windows 10/11 or macOS), you can specify a path to these:

Invoke-Lumos -Dark -DarkWallpaper c:\wallpaper\dark.png

Invoke-Lumos -Light -LightWallpaper /Users/markwragg/Pictures/light.jpg

If you'd like change the theme of your Office ProPlus installation on Windows 10/11, you can pass the -IncludeOfficeProPlus flag. It will update your Office Clients to switch to either the Dark or Light mode. Note that it requires a restart of your Office Applications before it takes effect.

Invoke-Lumos -Dark -IncludeOfficeProPlus

On Windows, when the System theme changes, Lumos applies it to the taskbar by broadcasting the same WM_SETTINGCHANGE/WM_THEMECHANGED messages Windows' own Settings app sends, rather than restarting Explorer. This reliably updates the taskbar, Start and Action Center, but not the chrome of any File Explorer windows you already had open - that appears to be a genuine Windows 11 limitation rather than something Lumos is missing (Microsoft's own PowerToys "Light Switch" module does the same broadcast and has the same open, unresolved issue). If that bothers you, add -RestartExplorer to fall back to restarting Explorer instead, which does pick up existing windows:

Invoke-Lumos -Dark -RestartExplorer

Scheduling

If you'd like Windows 10/11 to automatically switch from Light to Dark mode based on your local sunrise/sunset times, you can use the following cmdlet to add a Scheduled Task to do so (this cmdlet does not currently support macOS):

Register-LumosScheduledTask

This registers a "Lumos" scheduled task that runs Invoke-Lumos twice a day, at your local sunrise and sunset, plus a second "Lumos-Maintenance" task that runs once a week to keep those times current as sunrise/sunset drift through the year. Both tasks run as your own (non-administrator) user account.

You can specify any of the Invoke-Lumos switches above when registering the task to customize the result. For example:

Register-LumosScheduledTask -ExcludeApps -DarkWallpaper c:\wallpaper\dark.png -LightWallpaper c:\wallpaper\light.png

If you'd rather not have Lumos look up your location, you can specify fixed daily times yourself with -Sunrise/-Sunset, or reuse whatever schedule Windows' own Night Light feature (Settings > System > Display > Night light) is already configured with via -FromNightLight. Since neither of these needs to be kept in sync with the season, the "Lumos-Maintenance" task isn't registered in either case (and is removed if one was already registered from a previous, non-fixed run) - re-run the cmdlet if you want to pick up a later change:

Register-LumosScheduledTask -Sunrise '07:00' -Sunset '19:00'

Register-LumosScheduledTask -FromNightLight

Register-LumosScheduledTask returns the scheduled task(s) it registered, showing the source and times that were used, so you can confirm what was set up:

TaskName           Source       Schedule                           State
--------           ------       --------                           -----
Lumos              Location     Light 07:00, Dark 19:00            Ready
Lumos-Maintenance  Location     Weekly Wednesday 13:00             Ready

About

A PowerShell module for automatic switching between light and dark themes

Topics

Resources

Contributing

Stars

19 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages