Skip to content

Commit

Permalink
Make config directory on launch. (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jas-SinghFSU authored Dec 21, 2024
1 parent 2ffd602 commit c90a182
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -21,4 +34,5 @@ Object.assign(globalThis, {
});

ensureDirectory(TMP);
ensureFile(CONFIG);
App.add_icons(`${SRC_DIR}/assets`);

0 comments on commit c90a182

Please sign in to comment.