diff --git a/colors.scss b/colors.scss new file mode 120000 index 0000000..bc2d54d --- /dev/null +++ b/colors.scss @@ -0,0 +1 @@ +/home/pascal/.cache/wal/colors.scss \ No newline at end of file diff --git a/style.scss b/style.scss index 6db84a2..5970ab5 100644 --- a/style.scss +++ b/style.scss @@ -1,4 +1,4 @@ -@use "../../.cache/wal/colors.scss" as wal; +@use "./colors.scss" as wal; $fg-color: wal.$foreground; $bg-color: rgba(wal.$background, 0.8); diff --git a/theme.ts b/theme.ts index b90b85c..a795d8e 100644 --- a/theme.ts +++ b/theme.ts @@ -91,6 +91,47 @@ export async function setTheme(wallpaperPath: string) { const scss = `${agsDir}/style.scss` const css = `/tmp/ags-compiled-style.css` + // Create a symlink to the pywal colors file so SCSS can always find it + // even if the user moves their dotfiles, and provide a fallback if Pywal hasn't run yet. + try { + const walCache = `${HOME}/.cache/wal/colors.scss` + const walLocal = `${agsDir}/colors.scss` + + // Check if pywal cache exists, if not create a fallback + try { + await execAsync(`cat ${walCache}`) + } catch { + const fallback = ` + $wallpaper: ""; + $background: #1e1e1e; + $foreground: #d4d4d4; + $cursor: #d4d4d4; + $color0: #1e1e1e; + $color1: #f44747; + $color2: #6a9955; + $color3: #d7ba7d; + $color4: #569cd6; + $color5: #c586c0; + $color6: #4ec9b0; + $color7: #d4d4d4; + $color8: #808080; + $color9: #f44747; + $color10: #6a9955; + $color11: #d7ba7d; + $color12: #569cd6; + $color13: #c586c0; + $color14: #4ec9b0; + $color15: #d4d4d4; + ` + await execAsync(`mkdir -p ${HOME}/.cache/wal`) + await execAsync(["bash", "-c", `echo "${fallback}" > ${walCache}`]) + } + + await execAsync(`ln -sf ${walCache} ${walLocal}`) + } catch (e) { + console.error("Failed to setup pywal colors symlink:", e) + } + // Compile SCSS to CSS using the sass CLI await execAsync(`sass ${scss} ${css}`)