getlantern / systray

a cross platfrom Go library to place an icon and menu in the notification area

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows 11

ehsun7b opened this issue · comments

commented

fails completely. See the attachment.
Screen Shot 2022-01-11 at 5 37 13 pm

You may need to set the icon - I think it was a bit tricky with windows - you should have a setup something like:

func Run() {
	systray.Run(setup, close)
}

func setup() {
	systray.SetIcon(icon.Data())
...

Where I have this for my icon.go that is imported:

package icon

import (
	"fmt"
	"io/ioutil"
	"path/filepath"
)

const favicon_location = "editor/favicon.ico"

func Data() []byte {
	bytes, err := ioutil.ReadFile(filepath.FromSlash(favicon_location))
	if err != nil {
		fmt.Println("Failed to find '", favicon_location, "'")
		bytes = nil
	}
	return bytes
}

Hope this helps - Andy

P.S. You might also try this oldish guide - https://dev.to/osuka42/building-a-simple-system-tray-app-with-go-899 - but I think I had issues with Windows and slashes...

I don't know that any of us have an Windows 11 box to test against, so if anyone wants to contribute the code as a PR to make it work, I'll review and commit it.