Skip to content

Commit cae0357

Browse files
JulienMailleactions-user
authored andcommitted
WIP: light/dark moved to settings
1 parent 06f8ddf commit cae0357

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

default-dynamic.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ function toggleDark(setDark) {
138138
/* Init with light/dark mode from settings */
139139
toggleDark(settingsDark);
140140

141+
/* Hook user changes to toggle using a proxy for Spicetify.Config */
142+
Spicetify.Config = new Proxy(Spicetify.Config, {
143+
set(target, property, value) {
144+
if (property === "color_scheme") {
145+
// Wait 100ms for CSS variables to update
146+
setTimeout(() => {
147+
let dark = getComputedStyle(document.documentElement).getPropertyValue("--spice-dark").trim() === "#010101";
148+
toggleDark(dark);
149+
}, 100);
150+
}
151+
target[property] = value;
152+
return true;
153+
}
154+
});
155+
141156
waitForElement([".main-actionButtons"], (queries) => {
142157
// Add activator on top bar
143158
const buttonContainer = queries[0];

0 commit comments

Comments
 (0)