Skip to content

Commit b80700d

Browse files
committed
WIP: light/dark moved to settings
1 parent 06f8ddf commit b80700d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

default-dynamic.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@ 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)
148+
.getPropertyValue("--spice-dark").trim() === "#010101";
149+
toggleDark(dark);
150+
}, 100);
151+
}
152+
target[property] = value;
153+
return true;
154+
}
155+
});
156+
141157
waitForElement([".main-actionButtons"], (queries) => {
142158
// Add activator on top bar
143159
const buttonContainer = queries[0];

0 commit comments

Comments
 (0)