Sitelet https://github.com/tetsuo/xtray
Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xtray 🧃

Tiny macOS menubar utility for Go.

screenshot

Adds a system tray icon with a "Quit" menu item and simple callbacks.

Install

go get github.com/tetsuo/xtray

Requires macOS. Uses cgo and the Cocoa framework.

Usage

package main

import (
	"fmt"
	"log"

	"github.com/tetsuo/xtray"
)

func main() {
	if err := xtray.Tray(
		xtray.WithTooltip("MyApp"),
		xtray.WithIcon("icon.pdf"),
		xtray.WithLaunchCallback(func() {
			fmt.Println("Launched!")
		}),
		xtray.WithQuitCallback(func() {
			fmt.Println("Quitting...")
		}),
	); err != nil {
		log.Fatal(err)
	}
}

API

func Tray(opts ...Option) error

Launches the macOS menubar app and blocks until it is quit.

Options

Option Description
WithTooltip(string) Sets the tooltip shown on hover
WithIcon(string) Path to a .pdf tray icon
WithLaunchCallback(func()) Called after the app has finished launching
WithQuitCallback(func()) Called before the app terminates

License

MIT

About

macOS tray icon helper for Go

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages