Skip to content

tetsuo/xtray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Tiny macOS menubar utility for Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published