jscher2000 / switch-to-previous-active-tab

Firefox toolbar button to switch to the last accessed tab (and MRU popup)
Mozilla Public License 2.0
8 stars 1 forks source link

Is there an ability to detect system theme and switch automatically to dark mode? #7

Closed mystiquewolf closed 3 years ago

mystiquewolf commented 4 years ago

Using prefers-colors-scheme?

jscher2000 commented 4 years ago

Hmm, I think so. Would you want this because your system color scheme changes frequently?

Here's my initial assessment of the changes involved:

(1) background.js: Currently the extension has a property named oPrefs.blnDark with is either false (light) or true (dark). I could add an undefined value for auto. I guess technically it's not a boolean anymore, but it's easier than migrating data to a different property. Should I switch everyone who hasn't selected dark mode to Auto? Hmm...

(2) popup.html: Currently the Options tab just has a checkbox for dark mode, so that would need to be changed to a <select> or radio buttons for Auto, Light, or Dark.

(3) popup.js: Applying the value and saving changes to it would need rewrites.

Line 78 might look something like this:

if (oPrefs.blnDark === true || (oPrefs.blnDark === undefined && window.matchMedia('(prefers-color-scheme: dark)').matches)){

Lines 408-409 would need to handle the new form control(s).

mystiquewolf commented 4 years ago

My Ubuntu changes to dark and to light automatically at sunrise and sunset, and Firefox reflects that.

I've never done Firefox add-on development before, though i've done HTML/CSS/JS.

jscher2000 commented 3 years ago

I've added automatic theme detection in version 1.9.6. You'll need to open the Options panel and change the Color Scheme to Auto.

I don't have a way to test this. Does it work on yours?

mystiquewolf commented 3 years ago

Yes, it works perfectly! Also the new gray/grey color bars are much easier to look at in the dark. Thank you very much for this awesome and very useful addon! Maybe you should've notified other users about the new options with some title bar that can be removed when seen, but these changes are awesome!