style: use system scheme if available

This commit is contained in:
2 * r + 2 * t 2025-01-17 21:03:26 +11:00
parent c81616882e
commit 8751acf68f

10
app.tsx
View file

@ -1,4 +1,4 @@
import { execAsync, GLib, writeFileAsync } from "astal";
import { execAsync, GLib, readFileAsync, writeFileAsync } from "astal";
import { App } from "astal/gtk3";
import Bar from "./src/modules/bar";
import Launcher from "./src/modules/launcher";
@ -9,8 +9,12 @@ import Monitors from "./src/services/monitors";
import Players from "./src/services/players";
const loadStyleAsync = async () => {
if (!GLib.file_test(`${SRC}/scss/scheme/_index.scss`, GLib.FileTest.EXISTS))
await writeFileAsync(`${SRC}/scss/scheme/_index.scss`, '@forward "mocha";');
let scheme = "mocha";
if (GLib.file_test(`${CACHE}/scheme/current.txt`, GLib.FileTest.EXISTS)) {
const currentScheme = await readFileAsync(`${CACHE}/scheme/current.txt`);
if (GLib.file_test(`${SRC}/scss/scheme/${scheme}.scss`, GLib.FileTest.EXISTS)) scheme = currentScheme;
}
await writeFileAsync(`${SRC}/scss/scheme/_index.scss`, `@forward "${scheme}";`);
App.apply_css(await execAsync(`sass ${SRC}/style.scss`), true);
};