skhzhang / time-based-themes

Automatically change Firefox's theme based on the time
MIT License
121 stars 13 forks source link

macOS requires window focus before theme switches #12

Open samsalisbury opened 4 years ago

samsalisbury commented 4 years ago

This is more an annoyance than anything, but it would be great if the theme would switch immediately when the system dark mode setting switches. What it does on my machine (Catalina) is waits until I focus one of the Firefox windows before applying the relevant theme. I note that other extensions (e.g. DarkReader) are able to switch modes without focus so I guess there is a way to do this?

Thanks for this extension, it's really useful.

2zqa commented 3 years ago

Same problem on Windows, and presumably on linux distros too. This issue wouldn't exist if the system theme listener would work, but it seems the author also mentions it doesn't for some reason.

https://github.com/skhzhang/time-based-themes/blob/373cd42d99b4595514ec6aa2c8d76b6012b516cb/js/common.js#L88-L91

Here's an article on detecting the theme in js: https://medium.com/hypersphere-codes/detecting-system-theme-in-javascript-css-react-f6b961916d48

Perhaps a fallback timer could be used until this is sorted out?

skhzhang commented 3 years ago

I'm running the latest version of Windows (Win10 version 20H2) and this is now working for me at time of writing.

If you or anyone else is continuing to have this problem, can you please try the following

  1. Open Firefox to: https://codepen.io/kleinfreund/full/NmpKZM
  2. Change the system dark mode on your OS. Is the "OS exposes prefers-color-scheme as:" value changing from light to dark (or vice versa)?

I took a look at the Dark Reader code and they are doing something similar. If the problem is still happening, I'll have to continue digging into this but I wonder if this was fixed over time in a Firefox update.

Thanks!

2zqa commented 3 years ago

Sorry for the late response (happy new year!?). I just did some testing and it still appears to be non-functional. The codepen does work, however. I do have other extensions running, but I am not sure whether that could affect that(?)

I am running Windows 10 20H2 (19042.804).

https://user-images.githubusercontent.com/25235249/108720553-406a2200-7521-11eb-8ce6-2a22aed440dd.mp4