Skip to content

Commit

Permalink
Add tray_icon_path to config to allow overriding tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
3nprob committed Aug 4, 2022
1 parent b693aee commit 2845c46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion element.io/nightly/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@
"feature_spotlight": true,
"feature_video_rooms": true
},
"map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx"
"map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx",
"tray_icons": {}
}
3 changes: 2 additions & 1 deletion element.io/release/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@
"apiHost": "https://posthog.element.io"
},
"privacy_policy_url": "https://element.io/cookie-policy",
"map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx"
"map_style_url": "https://api.maptiler.com/maps/streets/style.json?key=fU3vlMsMn4Jb6dnEIFsx",
"tray_icons": {}
}
13 changes: 7 additions & 6 deletions src/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const argv = minimist(process.argv, {
// async to are initialised in setupGlobals()
let asarPath: string;
let resPath: string;
let iconPath: string;

if (argv["help"]) {
console.log("Options:");
Expand Down Expand Up @@ -192,11 +191,13 @@ async function setupGlobals(): Promise<void> {
}

// The tray icon
// It's important to call `path.join` so we don't end up with the packaged asar in the final path.
const iconFile = `element.${process.platform === 'win32' ? 'ico' : 'png'}`;
iconPath = path.join(resPath, "img", iconFile);
// It's important to call `path.join` for the bundled assets so we don't end up with the packaged asar in the final path.
const icon_path = process.platform === 'win32'
? (global.vectorConfig.tray_icons.ico || path.join(resPath, "img", 'element.ico'))
: (global.vectorConfig.tray_icons.ico || path.join(resPath, "img", 'element.png'));

global.trayConfig = {
icon_path: iconPath,
icon_path,
brand: global.vectorConfig.brand || 'Element',
};

Expand Down Expand Up @@ -418,7 +419,7 @@ app.on('ready', async () => {
// https://www.electronjs.org/docs/faq#the-font-looks-blurry-what-is-this-and-what-can-i-do
backgroundColor: '#fff',

icon: iconPath,
icon: global.trayConfig.icon_path,
show: false,
autoHideMenuBar: global.store.get('autoHideMenuBar', true),

Expand Down

0 comments on commit 2845c46

Please sign in to comment.