import AstalApps from "gi://AstalApps"; const astalApps: AstalApps.Apps = new AstalApps.Apps(); let appsList: Array = astalApps.get_list(); export function getApps(): Array { return appsList; } export function updateApps(): void { astalApps.reload(); appsList = astalApps.get_list(); } export function getAppsByName(appName: string): (Array|undefined) { let found: Array = []; getApps().map((app: AstalApps.Application) => { if(app.get_name().trim().toLowerCase() === appName.trim().toLowerCase() || (app?.wmClass && app.wmClass.trim().toLowerCase() === appName.trim().toLowerCase())) found.push(app); }); return (found.length > 0 ? found : undefined); } export function getAppIcon(appName: string): (string|undefined) { const found: (Array|undefined) = getAppsByName(appName); return found ? found[0]?.iconName : undefined; }