use state

This commit is contained in:
2 * r + 2 * t 2025-02-22 15:25:09 +11:00
parent 90cc9ac00f
commit c6dd4a4e97
5 changed files with 10 additions and 8 deletions

View file

@ -12,8 +12,8 @@ import { App } from "astal/gtk3";
const loadStyleAsync = async () => {
let schemeColours;
if (GLib.file_test(`${CACHE}/scheme/current.txt`, GLib.FileTest.EXISTS)) {
const currentScheme = await readFileAsync(`${CACHE}/scheme/current.txt`);
if (GLib.file_test(`${STATE}/scheme/current.txt`, GLib.FileTest.EXISTS)) {
const currentScheme = await readFileAsync(`${STATE}/scheme/current.txt`);
schemeColours = currentScheme
.split("\n")
.map(l => {
@ -32,7 +32,7 @@ App.start({
main() {
const now = Date.now();
loadStyleAsync().catch(console.error);
monitorFile(`${CACHE}/scheme/current.txt`, () => loadStyleAsync().catch(console.error));
monitorFile(`${STATE}/scheme/current.txt`, () => loadStyleAsync().catch(console.error));
<Launcher />;
<NotifPopups />;

1
env.d.ts vendored
View file

@ -1,3 +1,4 @@
declare const HOME: string;
declare const CACHE: string;
declare const STATE: string;
declare const SRC: string;

View file

@ -2,13 +2,14 @@
cd (dirname (status filename)) || exit 1
set -q XDG_RUNTIME_DIR && set bundle_dir $XDG_RUNTIME_DIR || set bundle_dir /tmp
set -q XDG_CACHE_HOME && set cache_dir $XDG_CACHE_HOME/caelestia || set cache_dir $HOME/.cache/caelestia
set -q XDG_RUNTIME_DIR && set -l bundle_dir $XDG_RUNTIME_DIR || set -l bundle_dir /tmp
set -q XDG_CACHE_HOME && set -l cache_dir $XDG_CACHE_HOME/caelestia || set -l cache_dir $HOME/.cache/caelestia
set -q XDG_STATE_HOME && set -l state_dir $XDG_STATE_HOME/caelestia || set -l state_dir $HOME/.local/state/caelestia
mkdir -p $cache_dir
./node_modules/.bin/esbuild app.tsx --bundle --outfile=$bundle_dir/caelestia.js \
--external:console --external:system --external:cairo --external:gettext --external:'file://*' --external:'gi://*' --external:'resource://*' \
--define:HOME=\"$HOME\" --define:CACHE=\"$cache_dir\" --define:SRC=\"(pwd)\" --format=esm --platform=neutral --main-fields=module,main
--define:HOME=\"$HOME\" --define:CACHE=\"$cache_dir\" --define:STATE=\"$state_dir\" --define:SRC=\"(pwd)\" --format=esm --platform=neutral --main-fields=module,main
gjs -m $bundle_dir/caelestia.js

View file

@ -18,7 +18,7 @@ export default class Math extends GObject.Object {
}
readonly #maxHistory = config.maxHistory;
readonly #path = `${CACHE}/math-history.json`;
readonly #path = `${STATE}/math-history.json`;
readonly #history: HistoryItem[] = [];
#variables: Record<string, string> = {};

View file

@ -11,7 +11,7 @@ export default class Players extends GObject.Object {
return this.instance;
}
readonly #path = `${CACHE}/players.txt`;
readonly #path = `${STATE}/players.txt`;
readonly #players: AstalMpris.Player[] = [];
readonly #subs = new Map<
JSX.Element,