From 0800b06ae35542308e5cf67072a8d33f2a3239bc Mon Sep 17 00:00:00 2001 From: OpenClaw Bot Date: Sat, 14 Mar 2026 16:24:25 +0000 Subject: [PATCH] Initial electron-tests tray app with split amd64/arm64 AppImage CI workflows --- index.html | 20 +++++++++++++++ main.js | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 39 +++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 index.html create mode 100644 main.js create mode 100644 package.json diff --git a/index.html b/index.html new file mode 100644 index 0000000..154b9de --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + Electron Tray Demo + + + +

Electron Tray Demo

+
+

This is a test desktop window for the Electron tray application.

+

Close window to hide to tray, use tray menu to show it again.

+
+ + diff --git a/main.js b/main.js new file mode 100644 index 0000000..625a499 --- /dev/null +++ b/main.js @@ -0,0 +1,70 @@ +const { app, BrowserWindow, Menu, Tray } = require('electron'); +const path = require('path'); + +let tray = null; +let mainWindow = null; + +function createWindow() { + mainWindow = new BrowserWindow({ + width: 700, + height: 420, + title: 'Electron Tray Demo', + webPreferences: { + contextIsolation: true, + nodeIntegration: false, + }, + }); + mainWindow.loadFile(path.join(__dirname, 'index.html')); + mainWindow.on('close', (event) => { + if (!app.isQuiting) { + event.preventDefault(); + mainWindow.hide(); + } + }); +} + +function createTray() { + const iconPath = path.join(__dirname, 'assets', 'trayTemplate.png'); + tray = new Tray(iconPath); + tray.setToolTip('Electron Tray Demo'); + + const contextMenu = Menu.buildFromTemplate([ + { + label: 'Show Window', + click: () => { + if (mainWindow) { + mainWindow.show(); + mainWindow.focus(); + } + }, + }, + { + label: 'Quit', + click: () => { + app.isQuiting = true; + app.quit(); + }, + }, + ]); + + tray.setContextMenu(contextMenu); + tray.on('double-click', () => { + if (mainWindow) { + mainWindow.show(); + mainWindow.focus(); + } + }); +} + +app.whenReady().then(() => { + createWindow(); + createTray(); + + app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) createWindow(); + }); +}); + +app.on('window-all-closed', () => { + // keep tray app alive on Linux/macOS +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..85ae48a --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "electron-tray-demo", + "version": "1.0.0", + "description": "Electron tray demo app", + "main": "main.js", + "author": "marksaitis", + "license": "MIT", + "scripts": { + "start": "electron .", + "build:linux:amd64": "electron-builder --linux AppImage --x64 --publish never", + "build:linux:arm64": "electron-builder --linux AppImage --arm64 --publish never" + }, + "devDependencies": { + "electron": "^30.1.2", + "electron-builder": "^24.13.3" + }, + "build": { + "appId": "io.swissline.electrontraydemo", + "productName": "electron_tray_demo", + "files": [ + "main.js", + "index.html", + "assets/**/*", + "package.json" + ], + "linux": { + "target": [ + { + "target": "AppImage", + "arch": [ + "x64", + "arm64" + ] + } + ], + "category": "Utility" + } + } +}