Build a Menu Bar Timer in Tauri 2 | System Tray Plugin Capstone

Codegiz — Built by Claude AI · Beginner ·📰 AI News & Updates ·2mo ago

About this lesson

A menu-bar app is a different animal from a regular desktop window. There is no dock icon and no big main window — just a small icon in the system tray that, when clicked, pops up a little panel. Hit the same icon again and the panel hides. Quit from a tray menu, not from a window close button. Tauri 2 has direct support for it via tauri::tray. Source code: https://github.com/GoCelesteAI/tauri_tomato This is the capstone of the Tauri Patterns for Production series. We build Tomato, a Pomodoro timer that lives in the menu bar. Click the tray icon, a 320 by 360 panel slides in with a 25:00 countdown and Start, Pause, Reset buttons. The session ticks down, an OS notification fires when it ends, and a daily-completions counter persists to disk. Every prior episode shows up somewhere: capabilities + bundle config (Ep 1), plugin-notification (Ep 3), WebviewWindow show/hide (Ep 4), plugin-store (Ep 5), Mutex AppState (Ep 7), and the CI matrix (Ep 9) still ships this app to three platforms without changes. What You'll Learn: - Menu-bar window config — visible: false, decorations: false, transparent: true, alwaysOnTop: true, skipTaskbar: true — five flags that turn a Tauri window into a tray popup. - TrayIconBuilder in the setup hook — registering the tray icon, attaching a right-click menu, handling left-click events. - show_menu_on_left_click(false) — left-click toggles your popup; right-click opens the menu. Standard menu-bar UX. - Mutex around TimerState — three coupled fields (running, started_at, remaining_secs) guarded by one Mutex, the same pattern from Episode 7. - Polling via setInterval calling invoke('tick') — simpler than events for a clock that updates twice a second. - app.notification().builder().title(...).body(...).show() — fire-and-forget OS notification when the session ends. - tauri-plugin-store for the daily counter — auto-save, JSON file on disk, survives quits and relaunches. - The capability permissions menu-bar apps need — core:window:allow-show

Original Description

A menu-bar app is a different animal from a regular desktop window. There is no dock icon and no big main window — just a small icon in the system tray that, when clicked, pops up a little panel. Hit the same icon again and the panel hides. Quit from a tray menu, not from a window close button. Tauri 2 has direct support for it via tauri::tray. Source code: https://github.com/GoCelesteAI/tauri_tomato This is the capstone of the Tauri Patterns for Production series. We build Tomato, a Pomodoro timer that lives in the menu bar. Click the tray icon, a 320 by 360 panel slides in with a 25:00 countdown and Start, Pause, Reset buttons. The session ticks down, an OS notification fires when it ends, and a daily-completions counter persists to disk. Every prior episode shows up somewhere: capabilities + bundle config (Ep 1), plugin-notification (Ep 3), WebviewWindow show/hide (Ep 4), plugin-store (Ep 5), Mutex AppState (Ep 7), and the CI matrix (Ep 9) still ships this app to three platforms without changes. What You'll Learn: - Menu-bar window config — visible: false, decorations: false, transparent: true, alwaysOnTop: true, skipTaskbar: true — five flags that turn a Tauri window into a tray popup. - TrayIconBuilder in the setup hook — registering the tray icon, attaching a right-click menu, handling left-click events. - show_menu_on_left_click(false) — left-click toggles your popup; right-click opens the menu. Standard menu-bar UX. - Mutex around TimerState — three coupled fields (running, started_at, remaining_secs) guarded by one Mutex, the same pattern from Episode 7. - Polling via setInterval calling invoke('tick') — simpler than events for a clock that updates twice a second. - app.notification().builder().title(...).body(...).show() — fire-and-forget OS notification when the session ends. - tauri-plugin-store for the daily counter — auto-save, JSON file on disk, survives quits and relaunches. - The capability permissions menu-bar apps need — core:window:allow-show
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
HEMN Technologies
Learn how HEMN Technologies is redefining the approach to AI adoption in businesses, focusing on a more proactive and innovative strategy rather than just adapting to AI.
Medium · AI
📰
Google and Ford are funding a push into the trades, the jobs their AI can’t do
Google and Ford are funding a push into trades jobs that AI can't do, highlighting the need for skilled workers in areas like electrician and technician roles
The Next Web AI
📰
$130 Billion In AI Data Centers Stalled. The Bottleneck Is Consent
$130 billion in AI data center projects are stalled due to local opposition, highlighting the need for developers to prioritize community consent
Forbes Innovation
📰
Global Trade Dynamics Q3 2026 — Geopolitical & Macroeconomic Analysis
Analyze global trade dynamics using AI and data analysis to understand geopolitical and macroeconomic trends
Dev.to AI
Up next
The Most Important Conversation in AI Right Now
Matthew Berman
Watch →