[New Module] Light Switch (#41987)

<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request
This pull request introduces a new module called "Light Switch" which
allows users to automatically switch between light and dark mode on a
timer.

![Light
Switch](https://github.com/user-attachments/assets/d24d7364-445f-4f23-ab5e-4b8c6a4147ab)

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] Closes: #1331
- [x] **Communication:** I've discussed this with core contributors
already. If the work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end-user-facing strings can be localized
- [x] **Dev docs:** Added/updated
- [x] **New binaries:** Added on the required places
- [x] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [x] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here:
[#5867](https://github.com/MicrosoftDocs/windows-dev-docs-pr/pull/5867)

<!-- Provide a more detailed description of the PR, other things fixed,
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

### Known bugs:
- Default settings not saving correctly when switching modes
- Issue: Sometimes when you switch from one mode to another, they are
supposed to update with new defaults but sometimes this fails for the
second variable. Potentially has to do with accessing the settings file
while another chunk of code is still updating.
- Sometimes the system looks "glitched" when switching themes

### To do:
- [x] OOBE page and assets
- [x] Logic to disable the chart when no location has been selected
- [x] Localization

### How to and what to test
Grab the latest installer from the pipeline below for your architecture
and install PowerToys from there.
- Toggle theme shortcutSystem only, Apps only, Both system and apps
selected
- Does changing the values on the settings page update the settings
file? %LOCALAPPDATA%/Microsoft/PowerToys/LightSwitch/settings.json
- Manual mode: System only, Apps only, Both system and apps selected
- Sunrise modes:  Are the times accurate?
- If you manage to let this run through sunset/rise does the theme
change?
- Set your theme to change within the next minute using manual mode and
set your device to sleepOpen your device and login once the time you set
has passed. --> Do your settings resync once the next minute ticks after
logging back into your device?
- Disable the service and ensure the tasks actually ends.
- While the module is disabled:
     - Make sure the shortcut no longer works
     - Make sure the last time you set doesn't trigger a theme change
- Bonus: Toggle GPO Configuration and make sure you are unable to enable
the module

---------

Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Gordon Lam (SH) <yeelam@microsoft.com>
This commit is contained in:
Jaylyn Barbee
2025-10-06 16:44:07 -04:00
committed by GitHub
parent ccc31c13ae
commit 0d5220561d
111 changed files with 5798 additions and 12 deletions

View File

@@ -3161,19 +3161,19 @@ Right-click to remove the key combination, thereby deactivating the shortcut.</v
<data name="Peek_ConfirmFileDelete.Description" xml:space="preserve">
<value>You'll be asked to confirm before files are moved to the Recycle Bin</value>
</data>
<data name="Peek_ActivationMethod.Header" xml:space="preserve">
<data name="Peek_ActivationMethod.Header" xml:space="preserve">
<value>Activation method</value>
</data>
<data name="Peek_ActivationMethod.Description" xml:space="preserve">
<data name="Peek_ActivationMethod.Description" xml:space="preserve">
<value>Use a shortcut or press the Spacebar when a file is selected</value>
<comment>Spacebar is a physical keyboard key</comment>
<comment>Spacebar is a physical keyboard key</comment>
</data>
<data name="Peek_ActivationMethod_CustomizedShortcut.Content" xml:space="preserve">
<data name="Peek_ActivationMethod_CustomizedShortcut.Content" xml:space="preserve">
<value>Custom shortcut</value>
</data>
<data name="Peek_ActivationMethod_SpaceBar.Content" xml:space="preserve">
<data name="Peek_ActivationMethod_SpaceBar.Content" xml:space="preserve">
<value>Spacebar</value>
</data>
</data>
<data name="FancyZones_DisableRoundCornersOnWindowSnap.Content" xml:space="preserve">
<value>Disable rounded corners when a window is snapped</value>
</data>
@@ -3261,6 +3261,15 @@ Activate by holding the key for the character you want to add an accent to, then
<data name="AlwaysOnTop_ShortDescription" xml:space="preserve">
<value>Pin a window</value>
</data>
<data name="LightSwitch_ThemeToggle_Shortcut.Header" xml:space="preserve">
<value>Theme toggle shortcut</value>
</data>
<data name="LightSwitch_ThemeToggle_Shortcut.Description" xml:space="preserve">
<value>Switch between light and dark mode</value>
</data>
<data name="LightSwitch_ForceDarkMode" xml:space="preserve">
<value>Toggle theme</value>
</data>
<data name="ColorPicker_ShortDescription" xml:space="preserve">
<value>Pick a color</value>
</data>
@@ -5224,6 +5233,117 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
<data name="GeneralPage_EnableViewDiagnosticDataText.Text" xml:space="preserve">
<value>Stores diagnostic data locally in .xml format; folder may include .etl files as well. May use up 1GB or more of disk space.</value>
</data>
<data name="Shell_LightSwitch.Content" xml:space="preserve">
<value>Light Switch</value>
</data>
<data name="LightSwitch_EnableToggleControl_HeaderText.Header" xml:space="preserve">
<value>Enable Light Switch</value>
</data>
<data name="LightSwitch.ModuleDescription" xml:space="preserve">
<value>Easily switch between light and dark mode - on a schedule, automatically, or with a shortcut.</value>
</data>
<data name="LightSwitch.ModuleTitle" xml:space="preserve">
<value>Light Switch</value>
</data>
<data name="LearnMore_LightSwitch.Text" xml:space="preserve">
<value>Learn more about Light Switch</value>
</data>
<data name="LightSwitch_BehaviorSettingsGroup.Header" xml:space="preserve">
<value>Behavior</value>
</data>
<data name="LightSwitch_EnableSettingsCard.Header" xml:space="preserve">
<value>Enable Light Switch</value>
</data>
<data name="LightSwitch_ShortcutsSettingsGroup.Header" xml:space="preserve">
<value>Shortcuts</value>
</data>
<data name="LightSwitch_ScheduleSettingsGroup.Header" xml:space="preserve">
<value>Schedule</value>
</data>
<data name="LightSwitch_ModeSettingsExpander.Header" xml:space="preserve">
<value>Mode</value>
</data>
<data name="LightSwitch_ModeSettingsExpander.Description" xml:space="preserve">
<value>Determine when dark mode should be turned on</value>
</data>
<data name="LightSwitch_ModeManual.Content" xml:space="preserve">
<value>Manual</value>
</data>
<data name="LightSwitch_ModeSunsetToSunrise.Content" xml:space="preserve">
<value>Sunset to sunrise</value>
</data>
<data name="LightSwitch_TurnOnDarkMode.Header" xml:space="preserve">
<value>Turn on dark mode</value>
</data>
<data name="LightSwitch_TurnOffDarkMode.Header" xml:space="preserve">
<value>Turn off dark mode</value>
</data>
<data name="LightSwitch_LocationSettingsCard.Header" xml:space="preserve">
<value>Location</value>
</data>
<data name="LightSwitch_LocationSettingsCard.Description" xml:space="preserve">
<value>Used to automatically calculate accurate sunrise and sunset times</value>
</data>
<data name="LightSwitch_OffsetSettingsCard.Header" xml:space="preserve">
<value>Offset (in minutes)</value>
</data>
<data name="LightSwitch_OffsetSettingsCard.Description" xml:space="preserve">
<value>Adjust the trigger time by starting earlier or later</value>
</data>
<data name="LightSwitch_LocationWarningBar.Title" xml:space="preserve">
<value>Location required</value>
</data>
<data name="LightSwitch_LocationWarningBar.Message" xml:space="preserve">
<value>Sync your location so Light Switch can calculate the correct sunrise- and sunset times</value>
</data>
<data name="LightSwitch_ApplyDarkModeExpander.Header" xml:space="preserve">
<value>Apply dark mode to</value>
</data>
<data name="LightSwitch_ApplyDarkModeExpander.Description" xml:space="preserve">
<value>Pick which parts of your PC should follow Light Switch</value>
</data>
<data name="LightSwitch_SystemCheckbox.Header" xml:space="preserve">
<value>System</value>
</data>
<data name="LightSwitch_SystemCheckbox.Description" xml:space="preserve">
<value>Taskbar, Start, and other system UI</value>
</data>
<data name="LightSwitch_AppsCheckbox.Header" xml:space="preserve">
<value>Apps</value>
</data>
<data name="LightSwitch_AppsCheckbox.Description" xml:space="preserve">
<value>Supported applications</value>
</data>
<data name="LightSwitch_LocationDialog.Title" xml:space="preserve">
<value>Select a location</value>
</data>
<data name="LightSwitch_LocationDialog.PrimaryButtonText" xml:space="preserve">
<value>Select</value>
</data>
<data name="LightSwitch_LocationDialog.SecondaryButtonText" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="LightSwitch_GetCurrentLocation.Text" xml:space="preserve">
<value>Get current location</value>
</data>
<data name="LightSwitch_LocationDialog_Description.Text" xml:space="preserve">
<value>To calculate the sunrise and sunset, Light Switch needs a location.</value>
</data>
<data name="LightSwitch_SunriseText.Text" xml:space="preserve">
<value>Sunrise</value>
</data>
<data name="LightSwitch_SunsetText.Text" xml:space="preserve">
<value>Sunset</value>
</data>
<data name="LightSwitch_LocationTooltip.Text" xml:space="preserve">
<value>Location</value>
</data>
<data name="LightSwitch_SunriseTooltip.Text" xml:space="preserve">
<value>Sunrise</value>
</data>
<data name="LightSwitch_SunsetTooltip.Text" xml:space="preserve">
<value>Sunset</value>
</data>
<data name="Close_NavViewItem.Content" xml:space="preserve">
<value>Close PowerToys</value>
<comment>Don't loc "PowerToys"</comment>
@@ -5321,6 +5441,22 @@ To record a specific window, enter the hotkey with the Alt key in the opposite m
<data name="UtilitiesHeader.Title" xml:space="preserve">
<value>Utilities</value>
</data>
<data name="Oobe_LightSwitch.Title" xml:space="preserve">
<value>Light Switch</value>
<comment>Product name. Do not localize this string</comment>
</data>
<data name="Oobe_LightSwitch.Description" xml:space="preserve">
<value>Light Switch automatically manages your Windows light and dark mode based on schedules, sunrise/sunset times, or manual control. Keep your system theme synchronized with your preferences and daily rhythm.</value>
<comment>Light Switch is a product name, do not localize</comment>
</data>
<data name="Oobe_LightSwitch_HowToUse.Text" xml:space="preserve">
<value>Open **PowerToys Settings** and enable Light Switch to set up automatic theme switching</value>
<comment>Light Switch is a product name, do not localize</comment>
</data>
<data name="Oobe_LightSwitch_TipsAndTricks.Text" xml:space="preserve">
<value>Use the **keyboard shortcut** to instantly toggle between light and dark modes, or set up **sunrise/sunset automation** for natural theme transitions.</value>
<comment>Light Switch is a product name, do not localize</comment>
</data>
<data name="DismissConflictBtn.[using:Microsoft.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Dismiss</value>
</data>