diff --git a/electron/tray.js b/electron/tray.js new file mode 100644 index 0000000..8383377 --- /dev/null +++ b/electron/tray.js @@ -0,0 +1,26 @@ +const { Tray, Menu, nativeImage } = require('electron'); +const path = require('path'); + +let tray = null; + +function createTray({ onShow, onHide, onQuit }) { + const iconPath = path.join(__dirname, '../assets/fox-tray.png'); + const icon = nativeImage.createFromPath(iconPath); + icon.setTemplateImage(true); + + tray = new Tray(icon); + tray.setToolTip('Fox'); + + tray.setContextMenu(Menu.buildFromTemplate([ + { label: 'Fox öffnen', accelerator: 'Cmd+Shift+F', click: onShow }, + { label: 'Fox verstecken', click: onHide }, + { type: 'separator' }, + { label: 'Beenden', click: onQuit }, + ])); + + tray.on('click', onShow); + + return tray; +} + +module.exports = { createTray };