Skip to content

shelepuginivan/systray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

systray

Go Reference Go Report Card License: MIT

Package systray is a toolkit-agnostic implementation of the StatusNotifierItem specification. It provides services for system tray hosts. This package does not provide capabilities for system tray applications (clients), it is intended to be used for building system trays themselves.

Package documentation is available at pkg.go.dev.

Installation

go get github.com/shelepuginivan/systray

Example

package main

import (
	"log"
	"os"

	"github.com/godbus/dbus/v5"
	"github.com/shelepuginivan/systray"
)

func main() {
	conn, _ := dbus.SessionBus()

	watcher := systray.NewWatcher(conn)
	host := systray.NewHost(conn, os.Getpid())

	watcher.RegisterHost(host)

	host.OnRegister(func(item *systray.Item) {
		log.Printf("%s (%s) is registered\n", item.Title, item.BusName())
	})

	host.OnUnregister(func(item *systray.Item) {
		log.Printf("%s (%s) is unregistered\n", item.Title, item.BusName())
	})

	if err := watcher.Listen(); err != nil {
		panic(err)
	}

	if err := host.Listen(); err != nil {
		panic(err)
	}

	select {}
}

License

MIT

About

Go implementation of the StatusNotifierItem specification for building system trays

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages