Skip to content

Commit

Permalink
Fix XDG_DATA_DIRS paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mimbrero committed Mar 24, 2022
1 parent 9116827 commit 1146355
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/tray-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,19 @@ export default class TrayManager {
}

private findIcon(name: string) {
let iconPath = path.join("${XDG_DATA_DIRS}", "icons/hicolor/512x512/apps/", name);
let iconPath = path.join(this.getDataDir("icons/hicolor/512x512/apps/"), name);

if (!fs.existsSync(iconPath))
iconPath = path.join(this.app.getAppPath(), "data/icons/hicolor/512x512/apps/", name);

return nativeImage.createFromPath(iconPath);
}

private getDataDir(iconPath: string) {
for (let dataDir of process.env.XDG_DATA_DIRS.split(":")) {
let fullPath = path.join(dataDir, iconPath);
if (fs.existsSync(fullPath))
return fullPath;
}
}
};

0 comments on commit 1146355

Please sign in to comment.