127 |
128 |
129 | {
133 | setCurrentEnabled(enabled);
134 | }}
135 | />
136 |
137 |
138 | {currentEnabled && (
139 |
140 |
141 | {
153 | setCurrentAppOverride(override);
154 | }}
155 | />
156 |
157 |
158 | {
167 | setCurrentTargetVibrancy(vibrancy);
168 | }}
169 | />
170 |
171 |
172 | )}
173 |
174 | );
175 | };
176 |
177 | export default definePlugin((serverAPI: ServerAPI) => {
178 | // load settings
179 | settings = loadSettingsFromLocalStorage();
180 |
181 | const backend = new Backend(serverAPI);
182 | const runningApps = new RunningApps();
183 |
184 | const applySettings = (appId: string) => {
185 | const vibrancy = settings.appVibrancy(appId);
186 | backend.applyVibrancy(vibrancy);
187 | };
188 |
189 | const resetSettings = () => {
190 | // NOTE: This code ignores night mode as we don't have a good way to interface with it.
191 | console.log("Resetting color values to defaults");
192 | backend.applyVibrancy(100);
193 | };
194 |
195 | const listenForRunningApps = (enabled: boolean) => {
196 | if (enabled) {
197 | console.log("Listening for actively running apps");
198 | runningApps.register();
199 | } else {
200 | console.log("Stopped listening for actively running apps");
201 | runningApps.unregister();
202 | }
203 | };
204 |
205 | // apply initially
206 | if (settings.enabled) {
207 | applySettings(RunningApps.active());
208 | }
209 |
210 | runningApps.listenActiveChange(() => applySettings(RunningApps.active()));
211 | listenForRunningApps(settings.enabled);
212 |
213 | return {
214 | title: