Development
Rebuilding SystemTrayMenu in Rust and Slint
Version 1 was a C# program with WinForms, Windows only. Version 3 is a rewrite in Rust with a Slint user interface: one codebase for Windows, macOS and Linux, about 20 MB of memory, no runtime to install. What the switch brought, and where it got stuck.
Why a rewrite
- Version 1: C# and WinForms, free under the GPL, more than 50,000 downloads and 870 stars on GitHub. The last release, 1.3.5, came out in September 2023.
- Version 2: a port to WPF with the same interface, never released. WPF runs on Windows only as well.
- The goal: the same folder menu on the Mac and on Linux, faster and leaner. Only a rewrite could do that.
Structure
Three crates, split by what depends on the system:
stm-core: folder model, sorting, search, cache and settings. No system code, with tests.stm-platform: icons, shortcuts, context menu, Quick Look, one module per system (windows-rs,objc2,zbus).stm-app: the interface in.slintfiles, plus tray, hotkeys and window handling.
What Rust and Slint brought
| Measured | For comparison | |
|---|---|---|
| Memory, Windows | 21 MB idle with the tray icon | 91 MB with the OpenGL renderer, 131 MB for a port of the old code to .NET 9 |
| Memory, macOS | 24 MB after 12 hours | 86 MB with the GPU renderer |
| Startup, macOS | 70 to 80 ms | |
| Idle, macOS | 0.0 % CPU, no wakeups in 10 minutes | |
| Program size | macOS 11.3 MB, Windows 13.3 MB, Linux 22.6 MB | one file, no runtime |
The biggest step was Slint’s software renderer on all three systems. With OpenGL, the hidden menu window kept its buffers in graphics memory. The switch also dropped FemtoVG, glutin and 76 entries from Cargo.lock. Slint bundles the translations for 28 languages into the binary, no files next to it.
Stumbling blocks
- The tray on each system: Windows remembers whether a tray icon is visible per program path. The Store version moves to a new folder with every update, so the icon was hidden again. On the Mac it sits in the menu bar. Linux shows it only with a StatusNotifier host (KDE, GNOME only with the AppIndicator extension), so the app asks over D-Bus first.
- Global hotkeys: Windows, macOS and X11 go through
global-hotkey. Wayland gives normal programs no global keys, so there it runs through the GlobalShortcuts portal (GNOME 48 and later, Ubuntu 25.04 and later). KDE 6.3 opens its shortcut settings on every bind, and the Plasma 5.27 portal binds nothing at all. There the app talks to kglobalaccel directly. - Windows on Wayland: a normal window may not place itself. The menu ended up in the middle of the screen, submenus ran off the edge. When XWayland is available, the menu runs through it.
- Drawing:
softbufferlost the alpha channel on Windows, and on the Mac every frame got an empty buffer and had to be drawn in full, so the menu stuttered. A small patched copy via[patch.crates-io]fixes both. - Signing and notarization: the Windows build has been signed since version 3.1.554. On the first day Chrome still blocked it as a “suspicious download”, because few people had downloaded it yet. Smart App Control refused to start fresh unsigned updates at all. On the Mac, Developer ID signing, Hardened Runtime and
notarytoolare ready in the build script; until notarization is live, the first start needs “Open Anyway”.
Testing without a screen
The UI tests run on Slint’s testing backend, without any window. A silent self-test starts the real app, presses keys and logs the timings. Every release passes the tests on Windows, macOS and Linux, and every Clippy warning counts as an error.
Disclosure: I’m the developer. Much of the code of version 3 is written by an AI coding assistant (Claude) under my direction; every release passes automated tests on Windows, macOS and Linux.
Free downloadMore about SystemTrayMenu
Read on: What’s new in SystemTrayMenu · Press kit · Slint