diff --git a/env.d.ts b/env.d.ts index c9f063b..665d2c3 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,4 +1,5 @@ declare const SRC: string; +declare const DATADIR: string; declare module 'inline:*' { const content: string; diff --git a/meson.build b/meson.build index c8476db..ed85f1f 100644 --- a/meson.build +++ b/meson.build @@ -1,57 +1,37 @@ -project('hyprpanel') +project( + 'hyprpanel', + default_options: [ + 'prefix=/usr', + ], +) -bindir = get_option('prefix') / get_option('bindir') -datadir = get_option('prefix') / get_option('datadir') / 'hyprpanel' +prefix = get_option('prefix') +bindir = prefix / get_option('bindir') +datadir = prefix / get_option('datadir') / meson.project_name() ags = find_program('ags', required: true) find_program('gjs', required: true) -src_file_list_process = run_command( - 'find', - 'src', - '-type', 'f', - '(', - '-name', '*.ts', - '-o', - '-name', '*.tsx', - '-o', - '-name', '*.scss', - ')', -) - -if src_file_list_process.returncode() != 0 - error('Failed to find source files.') -endif - -src_file_list = src_file_list_process.stdout().split('\n') - -all_sources = [] - -foreach file : src_file_list - file_stripped = file.strip() - if file_stripped != '' - all_sources += meson.project_source_root() / file_stripped - endif -endforeach - custom_target( 'hyprpanel_bundle', - input: all_sources, + input: files('app.ts'), command: [ ags, 'bundle', + '--define', 'DATADIR="' + datadir + '"', + '--root', meson.project_source_root(), meson.project_source_root() / 'app.ts', '@OUTPUT@', - '--src', meson.project_source_root(), ], - output: 'hyprpanel.js', + output: meson.project_name() + '.js', install: true, install_dir: datadir, + build_always_stale: true, ) configure_file( input: 'scripts/hyprpanel_launcher.sh.in', - output: 'hyprpanel', + output: meson.project_name(), configuration: {'DATADIR': datadir}, install: true, install_dir: bindir, diff --git a/package-lock.json b/package-lock.json index d15b8fb..9ac1852 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "hyprpanel", "version": "1.0.0", "license": "MIT", + "dependencies": { + "astal": "/usr/share/astal/gjs" + }, "devDependencies": { "@types/node": "^22.5.4", "@typescript-eslint/eslint-plugin": "^8.5.0", @@ -21,6 +24,9 @@ "typescript": "^5.6.2" } }, + "../../../../usr/share/astal/gjs": { + "license": "LGPL-2.1" + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -593,6 +599,10 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/astal": { + "resolved": "../../../../usr/share/astal/gjs", + "link": true + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", diff --git a/package.json b/package.json index a3380e7..86710f5 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,7 @@ "name": "hyprpanel", "version": "1.0.0", "description": "A customizable panel built for Hyprland.", - "main": "config.js", - "directories": { - "lib": "lib" - }, + "main": "app.ts", "scripts": { "lint": "eslint --config .eslintrc.js .", "lint:fix": "eslint --config .eslintrc.js . --fix", @@ -14,6 +11,9 @@ "keywords": [], "author": "", "license": "MIT", + "dependencies": { + "astal": "/usr/share/astal/gjs" + }, "devDependencies": { "@types/node": "^22.5.4", "@typescript-eslint/eslint-plugin": "^8.5.0", diff --git a/scripts/hyprpanel_launcher.sh.in b/scripts/hyprpanel_launcher.sh.in index 85260dd..c8121a5 100644 --- a/scripts/hyprpanel_launcher.sh.in +++ b/scripts/hyprpanel_launcher.sh.in @@ -1,7 +1,5 @@ #!/bin/sh -export HYPRPANEL_DATADIR="@DATADIR@" - if [ "$#" -eq 0 ]; then exec gjs -m "@DATADIR@/hyprpanel.js" else diff --git a/src/lib/session.ts b/src/lib/session.ts index 8b89f9f..3b2efa7 100644 --- a/src/lib/session.ts +++ b/src/lib/session.ts @@ -28,11 +28,13 @@ export function ensureFile(path: string): void { } } +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: GLib.getenv('HYPRPANEL_DATADIR') ?? SRC, + SRC_DIR: dataDir, }); ensureDirectory(TMP); diff --git a/tsconfig.json b/tsconfig.json index 6f2aacb..d076b0f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,11 +19,6 @@ "types": [], "experimentalDecorators": true, "jsx": "react-jsx", - "jsxImportSource": "/usr/share/astal/gjs/gtk3", - "paths": { - "astal": ["/usr/share/astal/gjs"], - "astal/*": ["/usr/share/astal/gjs/*"] - } - }, - "exclude": ["astal/gtk3/jsx-runtime.ts"] + "jsxImportSource": "astal/gtk3" + } }