diff --git a/vscode/caelestia-vscode-integration/caelestia-vscode-integration-1.1.0.vsix b/vscode/caelestia-vscode-integration/caelestia-vscode-integration-1.2.0.vsix similarity index 84% rename from vscode/caelestia-vscode-integration/caelestia-vscode-integration-1.1.0.vsix rename to vscode/caelestia-vscode-integration/caelestia-vscode-integration-1.2.0.vsix index f4745eb..6e16261 100644 Binary files a/vscode/caelestia-vscode-integration/caelestia-vscode-integration-1.1.0.vsix and b/vscode/caelestia-vscode-integration/caelestia-vscode-integration-1.2.0.vsix differ diff --git a/vscode/caelestia-vscode-integration/package.json b/vscode/caelestia-vscode-integration/package.json index bdd9541..5b6c930 100644 --- a/vscode/caelestia-vscode-integration/package.json +++ b/vscode/caelestia-vscode-integration/package.json @@ -2,7 +2,7 @@ "name": "caelestia-vscode-integration", "displayName": "caelestia-vscode-integration", "description": "VSCode integration for caelestia dotfiles", - "version": "1.1.0", + "version": "1.2.0", "publisher": "soramanew", "engines": { "vscode": "^1.96.0" diff --git a/vscode/caelestia-vscode-integration/src/extension.ts b/vscode/caelestia-vscode-integration/src/extension.ts index 2f81962..a47e189 100644 --- a/vscode/caelestia-vscode-integration/src/extension.ts +++ b/vscode/caelestia-vscode-integration/src/extension.ts @@ -5,23 +5,20 @@ import { join } from "path"; import { ConfigurationTarget, extensions, RelativePattern, workspace, type ExtensionContext } from "vscode"; import theme from "./theme"; -const statedir = () => process.env.XDG_STATE_HOME ?? join(homedir(), ".local", "state"); -const schemedir = () => join(statedir(), "caelestia", "scheme"); +const getSchemeDir = () => join(process.env.XDG_STATE_HOME ?? join(homedir(), ".local", "state"), "caelestia"); +const getSchemePath = () => join(getSchemeDir(), "scheme.json"); const update = async () => { - if (!existsSync(join(schemedir(), "current.txt"))) { + const schemePath = getSchemePath(); + + if (!existsSync(schemePath)) { console.log("No current scheme."); return; } // Update theme colours with scheme - const scheme = await readFile(join(schemedir(), "current.txt"), "utf-8"); - const colours = scheme.split("\n").reduce((acc, l) => { - const [name, hex] = l.split(" "); - acc[name] = `#${hex}`; - return acc; - }, {} as { [k: string]: string }); - + const scheme = JSON.parse(await readFile(schemePath, "utf-8")); + const colours = Object.fromEntries(Object.entries(scheme.colours).map(([n, c]) => [n, `#${c}`])); await writeFile(join(__dirname, "..", "themes", "caelestia.json"), JSON.stringify(theme(colours))); // Sync icon theme @@ -31,10 +28,9 @@ const update = async () => { /catppuccin-(latte|frappe|macchiato|mocha)/.test(workbench.get("iconTheme") ?? "") && extensions.getExtension("catppuccin.catppuccin-vsc-icons") ) { - const colourMode = await readFile(join(schemedir(), "current-mode.txt"), "utf-8"); workbench.update( "iconTheme", - `catppuccin-${colourMode === "light" ? "latte" : "mocha"}`, + `catppuccin-${scheme.mode === "light" ? "latte" : "mocha"}`, ConfigurationTarget.Global ); } @@ -44,7 +40,7 @@ const update = async () => { export const activate = (context: ExtensionContext) => { update(); - const watcher = workspace.createFileSystemWatcher(new RelativePattern(schemedir(), "current.txt")); + const watcher = workspace.createFileSystemWatcher(new RelativePattern(getSchemeDir(), "scheme.json")); context.subscriptions.push(watcher, watcher.onDidCreate(update), watcher.onDidChange(update)); - console.log(`Watching for changes to ${join(schemedir(), "current.txt")}`); + console.log(`Watching for changes to ${getSchemePath()}`); };