Fix: Add explicit GI_TYPELIB_PATH for AstalNotifd typelib resolution
This commit is contained in:
+67
-14
@@ -168,21 +168,74 @@ you should use the socket in the XDG_RUNTIME_DIR/colorshell.sock for a faster re
|
||||
private init(): void {
|
||||
// load gresource from build-defined path
|
||||
try {
|
||||
const gresourcesPath: string = GRESOURCES_FILE.startsWith('/') ? GRESOURCES_FILE : (GRESOURCES_FILE.split('/').filter(s =>
|
||||
s !== ""
|
||||
).map(path => {
|
||||
// support environment variables at runtime
|
||||
if(/^\$/.test(path)) {
|
||||
const env = GLib.getenv(path.replace(/^\$/, ""));
|
||||
if(env === null)
|
||||
throw new Error(`Couldn't get environment variable: ${path}`);
|
||||
|
||||
return env;
|
||||
// Handle missing GRESOURCES_FILE define (when running via AGS Home Manager)
|
||||
if (typeof GRESOURCES_FILE === "undefined" || !GRESOURCES_FILE) {
|
||||
// Try to find gresource in common locations
|
||||
// When symlinked via Home Manager, configDir is ~/.config/ags -> ../colorshell/src
|
||||
// We need to resolve the actual path of the colorshell directory
|
||||
const configDir = GLib.get_user_config_dir();
|
||||
const agsConfigFile = Gio.File.new_for_path(`${configDir}/ags/app.ts`);
|
||||
let colorshellBuildPath: string | null = null;
|
||||
|
||||
// Try to resolve the symlink to find the actual colorshell directory
|
||||
// When Home Manager symlinks ~/.config/ags -> ../colorshell/src,
|
||||
// we need to go up one level from src to find the colorshell root
|
||||
try {
|
||||
// Get the real path of app.ts (resolves symlinks)
|
||||
const appTsFile = Gio.File.new_for_path(`${configDir}/ags/app.ts`);
|
||||
if (appTsFile.query_exists(null)) {
|
||||
const realPath = appTsFile.get_path()!;
|
||||
// realPath will be something like /home/olivier/NixOS-New/colorshell/src/app.ts
|
||||
// Go up from src/ to get colorshell root, then to build/
|
||||
const srcDir = GLib.path_get_dirname(realPath);
|
||||
const colorshellDir = GLib.path_get_dirname(srcDir);
|
||||
colorshellBuildPath = `${colorshellDir}/build/resources.gresource`;
|
||||
}
|
||||
} catch (e) {
|
||||
// If symlink resolution fails, try absolute paths
|
||||
}
|
||||
return path;
|
||||
}).join('/'));
|
||||
this.#gresource = Gio.Resource.load(gresourcesPath);
|
||||
Gio.resources_register(this.#gresource);
|
||||
|
||||
const possiblePaths = [
|
||||
colorshellBuildPath,
|
||||
`${GLib.get_home_dir()}/NixOS-New/colorshell/build/resources.gresource`, // Absolute path (most reliable)
|
||||
`${configDir}/../colorshell/build/resources.gresource`, // Relative to ~/.config/ags
|
||||
`${GLib.get_user_config_dir()}/colorshell/build/resources.gresource`,
|
||||
`${GLib.get_home_dir()}/.config/colorshell/build/resources.gresource`,
|
||||
].filter(p => p !== null) as string[];
|
||||
|
||||
let gresourcesPath: string | null = null;
|
||||
for (const path of possiblePaths) {
|
||||
const file = Gio.File.new_for_path(path);
|
||||
if (file.query_exists(null)) {
|
||||
gresourcesPath = path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!gresourcesPath) {
|
||||
console.warn("Colorshell: GRESOURCES_FILE not defined and couldn't find gresource file. Icons may not be available.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.#gresource = Gio.Resource.load(gresourcesPath);
|
||||
Gio.resources_register(this.#gresource);
|
||||
} else {
|
||||
const gresourcesPath: string = GRESOURCES_FILE.startsWith('/') ? GRESOURCES_FILE : (GRESOURCES_FILE.split('/').filter(s =>
|
||||
s !== ""
|
||||
).map(path => {
|
||||
// support environment variables at runtime
|
||||
if(/^\$/.test(path)) {
|
||||
const env = GLib.getenv(path.replace(/^\$/, ""));
|
||||
if(env === null)
|
||||
throw new Error(`Couldn't get environment variable: ${path}`);
|
||||
|
||||
return env;
|
||||
}
|
||||
return path;
|
||||
}).join('/'));
|
||||
this.#gresource = Gio.Resource.load(gresourcesPath);
|
||||
Gio.resources_register(this.#gresource);
|
||||
}
|
||||
|
||||
// add icons
|
||||
Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!)
|
||||
|
||||
Reference in New Issue
Block a user