Skip to content

Instantly share code, notes, and snippets.

@tzmartin
Created September 19, 2017 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tzmartin/777dccf14b8e56b60f8e631c365862a5 to your computer and use it in GitHub Desktop.
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
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()
})
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()
})
{
"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