Created
September 19, 2017 10:41
-
-
Save tzmartin/777dccf14b8e56b60f8e631c365862a5 to your computer and use it in GitHub Desktop.
This repository contains two examples of how to use linux-icons with Electron for tray icons. Source: linux-icons-electron-example
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
const { | |
app, | |
Tray, | |
Menu, | |
BrowserWindow, | |
nativeImage | |
} = require('electron') | |
const icons = require('linux-icons') | |
let win | |
app.on('ready', function () { | |
win = new BrowserWindow({ | |
show: true | |
}) | |
let contextMenu = Menu.buildFromTemplate([{ | |
label: 'Quit', | |
accelerator: 'Command+Q', | |
selector: 'terminate:' | |
}]) | |
icons.getIconBuffer('google-chrome-tray', 22, [icons.Context.STATUS, icons.Context.PANEL], buffer => { | |
let tray = new Tray(nativeImage.createFromBuffer(buffer)) | |
tray.setToolTip('This is my application.') | |
tray.setContextMenu(contextMenu) | |
}) | |
}) | |
app.on('activate', () => { | |
win.show() | |
}) |
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
const { | |
app, | |
Tray, | |
Menu, | |
BrowserWindow, | |
nativeImage | |
} = require('electron') | |
const icons = require('linux-icons') | |
// Sync Example | |
let buffer = icons.getIconBuffer.sync('google-chrome-tray', 22, [icons.Context.STATUS, | |
icons.Context.PANEL | |
]) | |
let icon = nativeImage.createFromBuffer(buffer) | |
let win | |
app.on('ready', function () { | |
let tray = new Tray(icon) | |
win = new BrowserWindow({ | |
show: true | |
}) | |
let contextMenu = Menu.buildFromTemplate([{ | |
label: 'Quit', | |
accelerator: 'Command+Q', | |
selector: 'terminate:' | |
}]) | |
tray.setToolTip('This is my application.') | |
tray.setContextMenu(contextMenu) | |
}) | |
app.on('activate', () => { | |
win.show() | |
}) |
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
{ | |
"author": { | |
"name": "Bilal Elmoussaoui" | |
}, | |
"bundleDependencies": false, | |
"dependencies": { | |
"electron": "^1.6.10", | |
"linux-icons": "^1.1.1" | |
}, | |
"deprecated": false, | |
"description": "Linux Icons Electron Example", | |
"keywords": [ | |
"Linux", | |
"Icons", | |
"Electron" | |
], | |
"license": "MIT", | |
"main": "index.js", | |
"name": "linux-icons-electron-example", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"version": "1.1.2" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment