-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: monochrome tray icon #836
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,10 @@ async function generateIcons() { | |
name: 'icon', | ||
sizes: [16, 24, 32, 48, 256], | ||
}, | ||
// Linux (PNG) | ||
// Linux + Mac (PNG) | ||
favicon: { | ||
name: 'icon', | ||
pngSizes: [32, 512], | ||
pngSizes: [16, 32, 512], | ||
icoSizes: [], | ||
}, | ||
}) | ||
|
@@ -55,13 +55,32 @@ async function generateIcons() { | |
}, | ||
}) | ||
|
||
// Tray icon - Windows monochrome | ||
await icongen(originalMacTrayLightPath, outputPath, { | ||
ico: { | ||
name: 'icon-tray-win32-light', | ||
sizes: [16, 24, 32, 48, 256], | ||
}, | ||
}) | ||
await icongen(originalMacTrayDarkPath, outputPath, { | ||
ico: { | ||
name: 'icon-tray-win32-dark', | ||
sizes: [16, 24, 32, 48, 256], | ||
}, | ||
}) | ||
|
||
// Rename icon512.png -> icon.png | ||
await fs.rename(path.join(outputPath, 'icon512.png'), path.join(outputPath, 'icon.png')) | ||
// Rename icon32.png -> icon-tray-linux.png | ||
await fs.rename(path.join(outputPath, 'icon32.png'), path.join(outputPath, 'icon-tray-linux.png')) | ||
// Rename icon16.png -> icon-tray-mac.png | ||
// Rename icon32.png -> icon-tray-linux.png + [email protected] | ||
await fs.cp(path.join(outputPath, 'icon32.png'), path.join(outputPath, 'icon-tray-linux.png')) | ||
await fs.cp(path.join(outputPath, 'icon16.png'), path.join(outputPath, 'icon-tray-mac.png')) | ||
await fs.cp(path.join(outputPath, 'icon32.png'), path.join(outputPath, '[email protected]')) | ||
|
||
// Remove unused favicon | ||
await fs.unlink(path.join(outputPath, 'favicon.ico')) | ||
await fs.unlink(path.join(outputPath, 'icon16.png')) | ||
await fs.unlink(path.join(outputPath, 'icon32.png')) | ||
|
||
// Rename icon-tray-mac-(light|dark)16.png -> icon-tray-mac-(light|dark).png, icon-tray-mac-(light|dark)32.png -> icon-tray-mac-(light|dark)@2x.png | ||
await fs.rename(path.join(outputPath, 'icon-tray-mac-light16.png'), path.join(outputPath, 'icon-tray-mac-light.png')) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,9 @@ | |
*/ | ||
|
||
const { app, nativeTheme } = require('electron') | ||
const { isLinux } = require('./os.utils.js') | ||
const { isLinux, getPlatform } = require('./os.utils.js') | ||
const path = require('path') | ||
const { getAppConfig } = require('../app/AppConfig.ts') | ||
|
||
const icons = { | ||
// Executable's icon is used by default | ||
|
@@ -15,38 +16,40 @@ const icons = { | |
|
||
tray: { | ||
darwin: { | ||
default: require('../../img/icons/icon-tray-mac.png'), | ||
light: require('../../img/icons/icon-tray-mac-light.png'), | ||
dark: require('../../img/icons/icon-tray-mac-dark.png'), | ||
// These properties are not used, but the import is required to add the icon to the bundle | ||
// It will be used by electron internally | ||
default2x: require('../../img/icons/[email protected]'), | ||
light2x: require('../../img/icons/[email protected]'), | ||
dark2x: require('../../img/icons/[email protected]'), | ||
}, | ||
|
||
// This property is not used, but import is required to add the icon to the bundle. | ||
// It will be used by electron internally | ||
darwin_x2: { | ||
win32: { | ||
default: require('../../img/icons/icon.ico'), | ||
light: require('../../img/icons/icon-tray-win32-light.ico'), | ||
dark: require('../../img/icons/icon-tray-win32-dark.ico'), | ||
}, | ||
|
||
linux: { | ||
default: require('../../img/icons/icon-tray-linux.png'), | ||
light: require('../../img/icons/[email protected]'), | ||
dark: require('../../img/icons/[email protected]'), | ||
}, | ||
|
||
win32: require('../../img/icons/icon.ico'), | ||
|
||
linux: require('../../img/icons/icon-tray-linux.png'), | ||
}, | ||
} | ||
|
||
/** | ||
* Get tray icon for the given platform | ||
* | ||
* @param {'darwin'|'win32'|'cygwin'|string} [platform] platform otherwise current process.platform is used | ||
* @param {'light'|'dark'} [theme] theme for the darwin platform | ||
* Get tray icon | ||
*/ | ||
function getTrayIcon(platform, theme) { | ||
switch (platform ?? process.platform) { | ||
case 'darwin': | ||
return nativeTheme.shouldUseDarkColors || theme === 'dark' ? icons.tray.darwin.dark : icons.tray.darwin.light | ||
case 'win32': | ||
return icons.tray.win32 | ||
default: | ||
return icons.tray.linux | ||
} | ||
function getTrayIcon() { | ||
const platform = getPlatform() | ||
const monochrome = getAppConfig('monochromeTrayIcon') | ||
const theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light' | ||
const kind = monochrome ? theme : 'default' | ||
|
||
return icons.tray[platform][kind] | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires a restart for me to take effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be good now, you can merge)