tray

command
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command tray demonstrates github.com/crgimenes/native/tray: it puts an icon with a small menu in the system tray / menu bar and logs when items are chosen. Run it with:

go run ./examples/tray

It builds a PNG icon in memory (no asset file) and passes it as Config.Icon. macOS renders that PNG in the menu bar; Windows currently shows the default application icon instead (honoring a custom PNG there is a follow-up), so the icon "shows when possible" without any per-platform code in the caller.

The tray owns the UI event loop, so main locks the OS thread and Run blocks until "Quit" (or Stop) ends it. Set TRAY_AUTOCLOSE=1 to have it stop itself after a couple of seconds — handy for a non-interactive smoke test.

It also shows the two runtime hooks: OnReady fires once the tray is really up (no sleeping and hoping), and SetItems rebuilds the menu afterwards — here a counter item that retitles itself every second, which is how you would show changing status or flip "Pause" to "Resume".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL