Create system tray application with menu and notifications
✓Works with OpenClaudeYou are a desktop application developer. The user wants to create a system tray application with context menu functionality and desktop notifications.
What to check first
- Run
npm list electronto verify Electron is installed (version 13+) - Confirm your OS supports system tray (Windows, macOS, Linux all supported)
- Check
node --version— requires Node 14+
Steps
- Create main process file that initializes Electron app and creates tray instance with
new Tray(iconPath) - Define tray icon path — use PNG files (16x16 or 32x32 for best results) or system-provided icons
- Create context menu using
Menu.buildFromTemplate()with click handlers for each menu item - Attach menu to tray using
tray.setContextMenu(menu) - Set tray tooltip with
tray.setToolTip('Your App Name') - Create notification function using
new Notification()API or Electron's native notification support - Bind menu actions to trigger notifications and application behavior (show window, quit, etc.)
- Handle tray double-click or single-click to show/hide main window with
tray.on('click')
Code
const { app, BrowserWindow, Tray, Menu, Notification } = require('electron');
const path = require('path');
let tray = null;
let mainWindow = null;
app.on('ready', () => {
// Create main window (hidden initially)
mainWindow = new BrowserWindow({
width: 800,
height: 600,
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
});
mainWindow.loadFile('index.html');
// Create tray icon — use a simple PNG or built-in icon
const iconPath = path.join(__dirname, 'assets', 'icon.png');
tray = new Tray(iconPath);
tray.setToolTip('My Tray App');
// Create context menu
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show Window',
click: () => {
mainWindow.show();
mainWindow.focus();
}
},
{
label: 'Send Notification',
click: () => {
new Notification({
title: 'Hello from Tray',
body: 'This is a desktop notification',
icon: iconPath
}).show();
}
},
{
label: 'Open Dev Tools',
click: () => {
mainWindow.webContents.openDevTools();
}
},
{ type: 'separator' },
{
label: 'Quit',
click: () => {
app.quit();
}
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Desktop Apps Skills
Other Claude Code skills in the same category — free to download.
Electron Setup
Scaffold Electron desktop app with React or Vue
Tauri Setup
Scaffold Tauri desktop app with Rust backend
Desktop Auto Update
Set up automatic updates for desktop applications
Desktop IPC
Implement inter-process communication in desktop apps
Desktop Packaging
Package and distribute desktop apps (DMG, MSI, AppImage)
Want a Desktop Apps skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.