* Update meson * update * Use build_always_stale instead of manually defining files to track. * Clean up tsconfig
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { App } from 'astal/gtk3';
|
|
import { Gio } from 'astal/file';
|
|
import { GLib } from 'astal/gobject';
|
|
|
|
declare global {
|
|
const CONFIG: string;
|
|
const TMP: string;
|
|
const USER: string;
|
|
const SRC_DIR: string;
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
const dataDir = typeof DATADIR !== 'undefined' ? DATADIR : SRC;
|
|
|
|
Object.assign(globalThis, {
|
|
CONFIG: `${GLib.get_user_config_dir()}/hyprpanel/config.json`,
|
|
TMP: `${GLib.get_tmp_dir()}/hyprpanel`,
|
|
USER: GLib.get_user_name(),
|
|
SRC_DIR: dataDir,
|
|
});
|
|
|
|
ensureDirectory(TMP);
|
|
ensureFile(CONFIG);
|
|
App.add_icons(`${SRC_DIR}/assets`);
|