ags(scripts/apps): better icon-getter functions

This commit is contained in:
retrozinndev
2025-04-11 17:35:52 -03:00
parent e0417db94c
commit 8f028b3cb9
+15 -2
View File
@@ -36,7 +36,7 @@ export function getAppsByName(appName: string): (Array<AstalApps.Application>|un
return (found.length > 0 ? found : undefined); return (found.length > 0 ? found : undefined);
} }
export function getAppIcon(appName: string): (string|undefined) { export function getIconByAppName(appName: string): (string|undefined) {
if(Astal.Icon.lookup_icon(appName)) if(Astal.Icon.lookup_icon(appName))
return appName; return appName;
@@ -51,5 +51,18 @@ export function getAppIcon(appName: string): (string|undefined) {
if(Boolean(found)) if(Boolean(found))
return found?.iconName; return found?.iconName;
return "application-x-executable-symbolic"; return undefined;
}
export function getAppIcon(app: (string|AstalApps.Application)): (string|undefined) {
if(typeof app === "string")
return getIconByAppName(app);
if(app.iconName)
return app.iconName;
if(app.wmClass)
return getIconByAppName(app.wmClass);
return getIconByAppName(app.name);
} }