diff --git a/src/lib/session.ts b/src/lib/session.ts index ed2ccde0f..713c70b0a 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -13,6 +13,19 @@ export function ensureDirectory(path: string): void { if (!GLib.file_test(path, GLib.FileTest.EXISTS)) Gio.File.new_for_path(path).make_directory_with_parents(null); } +export function ensureFile(path: string): void { + const file = Gio.File.new_for_path(path); + const parent = file.get_parent(); + + if (parent && !parent.query_exists(null)) { + parent.make_directory_with_parents(null); + } + + if (!file.query_exists(null)) { + file.create(Gio.FileCreateFlags.NONE, null); + } +} + Object.assign(globalThis, { CONFIG: `${GLib.get_user_config_dir()}/hyprpanel/config.json`, TMP: `${GLib.get_tmp_dir()}/hyprpanel`, @@ -21,4 +34,5 @@ Object.assign(globalThis, { }); ensureDirectory(TMP); +ensureFile(CONFIG); App.add_icons(`${SRC_DIR}/assets`);