Skip to content

Commit

Permalink
Show app on tray icon double-click and adjust tray icon on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mawie81 committed Oct 25, 2015
1 parent 1ab7253 commit 75ef62c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ let mainWindow;
let appIcon;

function updateBadge(title) {
if (!app.dock) {
return;
}
let isOSX = !!app.dock;

const messageCount = (/\(([0-9]+)\)/).exec(title);
app.dock.setBadge(messageCount ? messageCount[1] : '');

if (isOSX) {
app.dock.setBadge(messageCount ? messageCount[1] : '');
if (messageCount) {
app.dock.bounce('informational');
}
}

if (messageCount) {
appIcon.setImage(path.join(__dirname, 'media', 'media/logo-blue.png'));
app.dock.bounce('informational');
appIcon.setImage(path.join(__dirname, 'media', 'media/logo-blue.png'));
} else {
appIcon.setImage(path.join(__dirname, 'media', 'logo-tray.png'));
}
Expand Down Expand Up @@ -64,17 +67,21 @@ function createMainWindow() {
return win;
}

function createTray() {
function createTray(mainWindow) {
appIcon = new Tray(path.join(__dirname, 'media', 'logo-tray.png'));
appIcon.setPressedImage(path.join(__dirname, 'media', 'logo-white.png'));
appIcon.setContextMenu(appMenu.trayMenu);

appIcon.on('double-clicked', () => {
mainWindow.show();
})
}

app.on('ready', () => {
Menu.setApplicationMenu(appMenu.mainMenu);

mainWindow = createMainWindow();
createTray();
createTray(mainWindow);

const page = mainWindow.webContents;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build": "npm run build-osx && npm run build-linux",
"build-osx": "electron-packager . $npm_package_productName --overwrite --out=dist --ignore='^/dist$' --prune --platform=darwin --arch=x64 --icon=media/logo-symbol.icns --app-bundle-id=me.wiehle.marcel.whatsdesktop --app-version=$npm_package_version --version=$npm_package_electronVersion && cd dist/WhatsDesktop-darwin-x64 && zip -ryXq9 ../WhatsDesktop-${npm_package_version}.zip WhatsDesktop.app",
"build-linux": "electron-packager . $npm_package_productName --overwrite --out=dist --ignore='^/dist$' --ignore='^/media/(?!logo-symbol.png$).*' --prune --platform=linux --arch=x64 --app-bundle-id=me.wiehle.marcel.whatsdesktop --app-version=$npm_package_version --version=$npm_package_electronVersion && cd dist/WhatsDesktop-linux-x64/ && zip -ryq9 ../WhatsDesktop-linux-\"$npm_package_version\".zip *",
"build-windows": "electron-packager . %npm_package_productName% --overwrite --out=dist --ignore='^/dist$' --ignore='^/media$' --prune --platform=win32 --arch=ia32 --icon=media/logo-symbol.ico --version=%npm_package_electronVersion% --version-string.ProductName=%npm_package_productName% --version-string.ProductVersion=%npm_package_electronVersion%"
"build-windows": "electron-packager . %npm_package_productName% --overwrite --out=dist --ignore='^/dist$' --prune --platform=win32 --arch=ia32 --icon=media/logo-symbol.ico --version=%npm_package_electronVersion% --version-string.ProductName=%npm_package_productName% --version-string.ProductVersion=%npm_package_electronVersion%"
},
"files": [
"index.js",
Expand Down

0 comments on commit 75ef62c

Please sign in to comment.