diff options
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/defaults.ts | 8 | ||||
| -rw-r--r-- | src/config/funcs.ts | 14 | ||||
| -rw-r--r-- | src/config/index.ts | 2 | ||||
| -rw-r--r-- | src/config/types.ts | 5 |
4 files changed, 26 insertions, 3 deletions
diff --git a/src/config/defaults.ts b/src/config/defaults.ts index 8a3927a..5365d86 100644 --- a/src/config/defaults.ts +++ b/src/config/defaults.ts @@ -97,6 +97,9 @@ export default { }, }, }, + sidebar: { + showOnStartup: false, + }, sideleft: { directories: { left: { @@ -144,4 +147,9 @@ export default { }, ], }, + calendar: { + webcals: [] as string[], // An array of urls to ICS files which you can curl + upcomingDays: 7, // Number of days which count as upcoming + notify: true, + }, }; diff --git a/src/config/funcs.ts b/src/config/funcs.ts index 473c502..72823eb 100644 --- a/src/config/funcs.ts +++ b/src/config/funcs.ts @@ -1,4 +1,4 @@ -import { GLib, monitorFile, readFileAsync, Variable } from "astal"; +import { GLib, monitorFile, readFileAsync, Variable, writeFileAsync } from "astal"; import config from "."; import { loadStyleAsync } from "../../app"; import defaults from "./defaults"; @@ -88,7 +88,15 @@ export const updateConfig = async () => { loadStyleAsync().catch(console.error); }; -export const initConfig = () => { +export const initConfig = async () => { monitorFile(CONFIG, () => updateConfig().catch(e => console.warn(`Invalid config: ${e}`))); - updateConfig().catch(e => console.warn(`Invalid config: ${e}`)); + await updateConfig().catch(e => console.warn(`Invalid config: ${e}`)); +}; + +export const setConfig = async (path: string, value: any) => { + const conf = JSON.parse(await readFileAsync(CONFIG)); + let obj = conf; + for (const p of path.split(".").slice(0, -1)) obj = obj[p]; + obj[path.split(".").at(-1)!] = value; + await writeFileAsync(CONFIG, JSON.stringify(conf, null, 4)); }; diff --git a/src/config/index.ts b/src/config/index.ts index d09a668..0cb8a60 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -9,6 +9,7 @@ export const { launcher, notifpopups, osds, + sidebar, sideleft, math, updates, @@ -18,5 +19,6 @@ export const { memory, storage, wallpapers, + calendar, } = config; export default config; diff --git a/src/config/types.ts b/src/config/types.ts index 51eb7cc..d3215c8 100644 --- a/src/config/types.ts +++ b/src/config/types.ts @@ -50,6 +50,8 @@ export default { "osds.lock.spacing": NUM, "osds.lock.caps.hideDelay": NUM, "osds.lock.num.hideDelay": NUM, + // Sidebar + "sidebar.showOnStartup": BOOL, // Sideleft "sideleft.directories.left.top": STR, "sideleft.directories.left.middle": STR, @@ -69,4 +71,7 @@ export default { "memory.interval": NUM, "storage.interval": NUM, "wallpapers.paths": OBJ_ARR({ recursive: BOOL, path: STR }), + "calendar.webcals": ARR(STR), + "calendar.upcomingDays": NUM, + "calendar.notify": BOOL, } as { [k: string]: string | string[] | number[] }; |