Use Native Linux icons on NodeJS
Improve Linux support on your NodeJS application by using system icon themes. The icons should be placed under one of the freedesktop icons location standards like /usr/share/icons/hicolor/
The current version supports:
- Inherits
- Sizes (SVG icons are resized when using
getIconBuffer
) - Icon Contexts
Install the package
npm install --save linux-icons
In order to get the full path of an icon
const icons = require('linux-icons')
let iconPath = icons.getIcon.sync('myicon-name', 22, icons.Context.STATUS)
Async
const icons = require('linux-icons')
icons.getIcon('myicon-name', 22, icons.Context.STATUS, iconPath => {
console.log(iconPath)
})
Or to get the buffer of it
const icons = require('linux-icons')
let icon = icons.getIconBuffer.sync('myicon-name', 22, icons.Context.STATUS)
Async
const icons = require('linux-icons')
icons.getIconBuffer('myicon-name', 22, icons.Context.STATUS, buffer => {
console.log(buffer)
})
Note: Electron tray icons does not support SVG icons. You will have to use getIconBuffer
with nativeImage.createFromBuffer
. See the examples folder.
- Auto-detect the DE and get the right icon theme name
- Async version
- Clean the code!
- Scaling Factor