Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zacbowden opened this issue Feb 19, 2020 · 95 comments
Open

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

zacbowden opened this issue Feb 19, 2020 · 95 comments
Labels
Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-New PowerToy Suggestion for a PowerToy

Comments

@zacbowden
Copy link

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 zacbowden changed the title Automatic theme switch based on time or sunset/sunrise Automatic Windows 10 theme switch based on time or sunset/sunrise Feb 19, 2020
@zacbowden zacbowden changed the title Automatic Windows 10 theme switch based on time or sunset/sunrise Automatic Windows 10 theme switch based on time or sunset/sunrise [Feature Suggestion] Feb 19, 2020
@crutkas crutkas added Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-New PowerToy Suggestion for a PowerToy labels Feb 19, 2020
@crutkas
Copy link
Member

crutkas commented Feb 19, 2020

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

@niels9001
Copy link
Contributor

niels9001 commented Feb 22, 2020

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

@ismaelestalayo
Copy link

ismaelestalayo commented Feb 22, 2020

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)

@niels9001
Copy link
Contributor

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

@crutkas
Copy link
Member

crutkas commented Feb 23, 2020

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

@mikeparkie
Copy link

mikeparkie commented Feb 23, 2020

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"

@crutkas
Copy link
Member

crutkas commented Feb 23, 2020

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

@crutkas crutkas added this to the Suggested Ideas milestone Mar 9, 2020
@bradleybowman
Copy link

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?)

@mikeparkie
Copy link

mikeparkie commented Mar 12, 2020

@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).

@BradleyBartlett
Copy link

BradleyBartlett commented Mar 12, 2020 via email

@mikeparkie
Copy link

@BradleyBartlett whoopsie, sorry about that :)

@niels9001
Copy link
Contributor

niels9001 commented Mar 16, 2020

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

@bradleybowman
Copy link

bradleybowman commented Mar 16, 2020

@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

@mikeparkie
Copy link

@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 :)

@niels9001
Copy link
Contributor

@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.

@Cossey
Copy link

Cossey commented Mar 19, 2020

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

@Armin2208
Copy link

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?

@niels9001
Copy link
Contributor

cc @crutkas

@crutkas
Copy link
Member

crutkas commented Jun 6, 2020

@Armin2208, lets chat! [email protected]

@Jay-o-Way
Copy link
Collaborator

Jay-o-Way commented Jul 24, 2020

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.

@niels9001 niels9001 changed the title Automatic Windows 10 theme switch based on time or sunset/sunrise [Feature Suggestion] [Feature Suggestion] Automatic Windows 10 theme switch based on time or sunset/sunrise Aug 19, 2020
@IndefiniteBen
Copy link

IndefiniteBen commented Nov 1, 2023

And search results never mention f.lux

My guess is that many people stopped using f.lux when they added night light to Windows.
If you want a simple app for changing dark/light mode there's Auto Dark Mode.
Most people probably use this app, which is why they don't mention f.lux.

@Regenhardt
Copy link

Will this include a hotkey to manually toggle dark mode? Tha's really all I'm looking for.

@SamChaps
Copy link
Contributor

SamChaps commented Jan 13, 2024

I'm currently starting the implementation of such a module. I am planning on doing something very similar to Night light on Windows 11. Here is a brief overview of the features I am planning to implement:

  • Provide a hotkey that changes Window's theme.
  • Provide a system tray icon that changes Window's theme on click.
  • Provide a theme change scheduling based on sunset/sunrise (if location services are enabled) or custom hours.

@niels9001
Copy link
Contributor

I'm currently starting the implementation of such a module. I am planning on doing something very similar to Night light on Windows 11. Here a brief overview of the features I am planning to implement:

  • Provide a hotkey that changes Window's theme.
  • Provide a system tray icon that changes Window's theme on click.
  • Provide a theme change scheduling based on sunset/sunrise (if location services are enabled) or custom hours.

Aweeeesome 😄🔥.

Would it make sense to, instead of systray, put the toggle in the PT quick access flyout? It's an additional click, but does save space in the systray area - and it's not something you'd press 10 times a day 😄

@SamChaps
Copy link
Contributor

@niels9001 yes, that's another good option. I was thinking of a dedicated tray item (that we can disable) for ease of access by users that are more mouse-oriented. I'd like to facilitate my team to test our app and toggle theme easily. But perhaps it is a bit overkill.

@Spiritreader
Copy link

I'm currently starting the implementation of such a module. I am planning on doing something very similar to Night light on Windows 11. Here a brief overview of the features I am planning to implement:

* Provide a hotkey that changes Window's theme.

* Provide a system tray icon that changes Window's theme on click.

* Provide a theme change scheduling based on sunset/sunrise (if location services are enabled) or custom hours.

Wow, that sounds awesome!

I have two questions:
Does that mean Microsoft's stance about allowing private APIs in powertoys has changed?
Or will there be / is there a new public theme switching API that everyone can use?

@OwenCD
Copy link

OwenCD commented Jan 13, 2024

Been looking for this to exist in PT since Windows doesn't have this natively - I think this a perfect place/tool for such a feature. Glad to hear its being worked on! Happy to help in any way I can

@SamChaps
Copy link
Contributor

@Spiritreader I don't think I can say anything about Microsoft's stance. I won't use any private APIs. I'll probably have to use the hacks discussed in this thread. I am not aware if there is any work or plan for creating a public theme switching API. PowerToys is just the perfect place to introduce such feature if we want it to eventually be picked up by Windows.

@ubaldot
Copy link

ubaldot commented May 22, 2024

I have installer Powertoys v.0.81.0 but I cannot find the auto dark mode feature. Is it available or is it still a WIP? :)

@Hedreon
Copy link

Hedreon commented May 22, 2024

I have installer Powertoys v.0.81.0 but I cannot find the auto dark mode feature. Is it available or is it still a WIP? :)

Very likely it's still a WIP. It seems I've been living under a rock so please refer to Ben's message instead. 👇🏼

@IndefiniteBen
Copy link

If you see the Test for PowerToys project and Help wanted project, to which this issue/feature has been added, this makes me think WIP does not describe the status accurately.

Unless @SamChaps or someone else is working on this in the background, it looks like no one is currently working on this and there is nothing currently "in progress" on this feature.

@LNKLEO
Copy link

LNKLEO commented Jan 8, 2025

I will be working on this.

@OwenCD
Copy link

OwenCD commented Jan 29, 2025

The features in auto dark mode seem very good a relevant to this application - https://github.com/AutoDarkMode/Windows-Auto-Night-Mode

Auto Dark Mode has a range of customization options. You can set custom hours for theme switching, create exceptions to prevent the app from switching your Windows theme during certain tasks, or have the app enable dark mode whenever your device is unplugged. The app also supports hotkeys for switching to themes and preventing themes from switching.

@IndefiniteBen
Copy link

@OwenCD This has been discussed earlier in this thread.

Armin said that it was pretty much ready for integration: #1331 (comment)

Then later when I asked for an update, Spiritreader mentioned that due to a Windows registry change, integrating ADM into powertoys would no longer be possible: #1331 (comment)

Other solutions are discussed which you can read through after those comments, if you are interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted We encourage anyone to jump in on these and submit a PR. Idea-New PowerToy Suggestion for a PowerToy
Projects
Status: ⚠️Needs Walkthrough
Status: To do
Development

No branches or pull requests