PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

light/dark mode switch based key, on time or sunset/sunrise

Open zacbowden opened this issue 4 years ago • 92 comments

An option inside Power Toys that automatically switches between Windows 10's light and dark theme at a certain time of day, or at sunset and sunrise, similar to how Night Light does in Windows 10. Feature could also be configurable so that the user can choose to have the automated process switch only app theme, or both app and system theme.

zacbowden avatar Feb 19 '20 22:02 zacbowden

We're prioritizing v1 work items but if a community member wants to help build this out, happy to dedicate time to this.

crutkas avatar Feb 19 '20 22:02 crutkas

Really like this idea! Here's a mock-up for the settings screen this feature would need to have.

AutoTheming

XAML source (WinUI 3.0 Alpha) in this repo: https://github.com/niels9001/PowerToysUXWinUI3Alpha

niels9001 avatar Feb 22 '20 19:02 niels9001

It’d also be very nice if we could choose two existing themes and set each one for day/night time (so not only the Light/Dark theme is changed, but also the wallpaper)

ismaelestalayo avatar Feb 22 '20 21:02 ismaelestalayo

Somebody referenced this project that does this: https://github.com/Armin2208/Windows-Auto-Night-Mode

niels9001 avatar Feb 22 '20 22:02 niels9001

Cool project but that is GPL v3. We cannot use any source code from that project due to that license.

crutkas avatar Feb 23 '20 03:02 crutkas

I do this in EventGhost using registry and cmd. Just chipping in case it helps.

Light: REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /V AppsUseLightTheme /T REG_DWORD /D 1 /F

CMD: "%localappdata%\Microsoft\Windows\Themes\Day.theme"

Dark: REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /V AppsUseLightTheme /T REG_DWORD /D 0 /F

CMD: "%localappdata%\Microsoft\Windows\Themes\Night.theme"

mikeparkie avatar Feb 23 '20 16:02 mikeparkie

Thanks @mikeparkie! Investigation is a massive part of the work!!!

crutkas avatar Feb 23 '20 16:02 crutkas

I also use the exact commands @mikeparkie referenced. I think I found them through a Google search, but I can confirm it works.

I use Task Scheduler; the action is 'Start a Program', command reg, with the argument set for light/dark theme. Granted, this is just a timed trigger.

One quirk I've noticed with this method: if you leave a File Explorer window open during the change, most of the Explorer UI honors the switch--the 'folder contents' portion of the window does not. It requires closing the File Explorer window and opening a new one to produce the expected result of a fully themed Explorer window.

Point is, it works, but it's not always elegant (not sure if it's possible to force reload the open windows entirely?)

bradleybowman avatar Mar 12 '20 18:03 bradleybowman

@bradleybowman agreed, it's relatively crude in it's execution, but it works for the most part. And actually I didn't face any issues with the UI, other than the ribbon redraws first, followed by the rest of the frame/contents, take about 2 seconds in total. Enough to notice a transition.

If it's a content/icon refresh, then theres always the "ie4uinit.exe -show" command which should reload the icon cache (but I'm guessing a little there).

mikeparkie avatar Mar 12 '20 21:03 mikeparkie

Wrong @ in the comment

BradleyBartlett avatar Mar 12 '20 21:03 BradleyBartlett

@BradleyBartlett whoopsie, sorry about that :)

mikeparkie avatar Mar 12 '20 21:03 mikeparkie

Luna is a new project up on GitHub that does this.. Light-weight and made with WPF. MIT license (@crutkas)

https://github.com/adrianmteo/Luna

niels9001 avatar Mar 16 '20 11:03 niels9001

@mikeparkie I noticed last night when the theme switched, it did redraw the File Explorer window properly. It's probably worth noting I'm on the 'Insider Fast Ring', so there's always the factor that I'm on a potentially unstable build.

@niels9001 I checked out Luna. The interface is slick and in my opinion just how an average end user would like to set up light/dark mode switching

If you check through that project though, it's essentially doing the same thing I am. Luna creates the Task Scheduler tasks at the times you select, and if you check out Luna/Helpers/RegistryHandler.cs:

(Hopefully I'm allowed to crosspost this, if not please let me know and I'll remove)

public static void AppsUseLightTheme(bool enabled)
        {
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", true);

            if (key != null)
            {
                key.SetValue("AppsUseLightTheme", enabled ? 1 : 0, RegistryValueKind.DWord);
            }
        }

^ It uses the same method that Mike and I mentioned.

Nothing against the Luna app, I really do like the interface...it just seems that, at present, theme switching falls into the 'registry hack not-elegant-but-it-works' category

bradleybowman avatar Mar 16 '20 18:03 bradleybowman

@bradleybowman likewise, I'm also running fast ring insider builds. I can't whether my previous non-insider builds had the issue or not. I'm not rebuilding to test it out :)

mikeparkie avatar Mar 16 '20 18:03 mikeparkie

@bradleybowman No problem, I'm excited about this. It's a 'small' feature but I think a lot of users would be happy with it. Are you guys planning to pick this up? I'd be happy to help with the XAML/UX within Settings.

niels9001 avatar Mar 18 '20 06:03 niels9001

As others have mentioned above I also use the Registry value triggered at specific times in the task scheduler to toggle on dark mode at night.

However - I also use this registry key as well to make sure dark/light mode is applied to Windows:

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" /V SystemUsesLightTheme /T REG_DWORD /D 1 /F

Cossey avatar Mar 19 '20 03:03 Cossey

Cool project but that is GPL v3. We cannot use any source code from that project due to that license.

Hello! I am the developer of the Auto Dark Mode App for Windows. I am interested in working together as I could change the license. Especially creating a new public theming API would be in the interest of all of us. In return of sharing my code with you I need some help. How can I contact you?

Armin2208 avatar Jun 04 '20 20:06 Armin2208

cc @crutkas

niels9001 avatar Jun 04 '20 20:06 niels9001

@armin2208, lets chat! [email protected]

crutkas avatar Jun 06 '20 04:06 crutkas

I had the exact same idea (connecting light/dark theme to Nightlight) a while ago. I sent in the suggestion via Windows Feedback hub. Seems like the best place for this idea, to me - really hoping it'll make it's way into Windows some day. But when Windows itself does not have this option, PowerToys looks like a good alternative.

Jay-o-Way avatar Jul 24 '20 11:07 Jay-o-Way

Any news? Looking forward to this.

Firstly, we have agreed for a solution. Auto Dark Mode will be a part of PowerToys in the future.

But this feature will be a post-release feature. The PowerToys team is busy with finalizing their current work, while we are busy to improve our new theme switch engine. And the Auto Dark Mode team has a little break ;)

You can expect this feature in a PowerToys Beta in november or december.

Armin2208 avatar Sep 13 '20 16:09 Armin2208

@Armin2208 any news on this :)?

niels9001 avatar Dec 08 '20 22:12 niels9001

no

Armin2208 avatar Dec 09 '20 15:12 Armin2208

By the way, I've read requests in the Win Feedback to connect the light/dark mode to (the timing of) the nightlight function and apparently MS is really considering this. https://aka.ms/AAanro0

Jay-o-Way avatar Dec 21 '20 16:12 Jay-o-Way

By the way, I've read requests in the Win Feedback to connect the light/dark mode to (the timing of) the nightlight function and MS is really considering this.

Yey that would be the best thing

tiziodcaio avatar Dec 21 '20 16:12 tiziodcaio

Paging @Armin2208 - you should add your project to PowerToys!

krysjez avatar Mar 04 '21 19:03 krysjez

@crutkas Any update on this please? I just installed Auto-Night-Mode for now, but it'd be nice to be in the PowerToys package too.

IndefiniteBen avatar Mar 17 '21 15:03 IndefiniteBen

@IndefiniteBen not something we've added in, we have the help wanted tag. @Armin2208 was interested in adding it in.

crutkas avatar Mar 30 '21 04:03 crutkas

yes I wanted to add this as post release feature. But we all know Power Toys 1.0 was delayed. But I will probably add this earlier then :D no worries.

Armin2208 avatar Mar 30 '21 11:03 Armin2208

This would be a great feature to have @Armin2208 Please let us know if there's been any progress or if you have your plate full and help is still wanted

ghost avatar Apr 13 '21 13:04 ghost