diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-01 22:01:55 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-01 22:01:55 +1100 |
| commit | 9c1cc00965170b85146ddcdaff9eeb522e1a8d48 (patch) | |
| tree | 7190907197ce94aef1d23f763935bb90bc02be0b /src/services/schemes.ts | |
| parent | launcher: scheme autocomplete (diff) | |
| download | caelestia-shell-9c1cc00965170b85146ddcdaff9eeb522e1a8d48.tar.gz caelestia-shell-9c1cc00965170b85146ddcdaff9eeb522e1a8d48.tar.bz2 caelestia-shell-9c1cc00965170b85146ddcdaff9eeb522e1a8d48.zip | |
launcher: wallpaper action
Diffstat (limited to 'src/services/schemes.ts')
| -rw-r--r-- | src/services/schemes.ts | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/services/schemes.ts b/src/services/schemes.ts index 07d6ded..4c51744 100644 --- a/src/services/schemes.ts +++ b/src/services/schemes.ts @@ -1,3 +1,4 @@ +import { basename } from "@/utils/strings"; import { execAsync, GLib, GObject, monitorFile, property, readFileAsync, register } from "astal"; import type { IPalette } from "./palette"; @@ -19,10 +20,6 @@ export default class Schemes extends GObject.Object { return this.#map; } - #schemePathToName(path: string) { - return path.slice(path.lastIndexOf("/") + 1, path.lastIndexOf(".")); - } - async parseScheme(path: string) { const schemeColours = (await readFileAsync(path)).split("\n").map(l => l.split(" ")); return schemeColours.reduce((acc, [name, hex]) => ({ ...acc, [name]: `#${hex}` }), {} as IPalette); @@ -30,8 +27,7 @@ export default class Schemes extends GObject.Object { async update() { const schemes = await execAsync(`find ${DATA}/scripts/data/schemes/ -type f`); - for (const scheme of schemes.split("\n")) - this.#map[this.#schemePathToName(scheme)] = await this.parseScheme(scheme); + for (const scheme of schemes.split("\n")) this.#map[basename(scheme)] = await this.parseScheme(scheme); this.notify("map"); } |