38 lines
595 B
Go
38 lines
595 B
Go
|
package tray
|
||
|
|
||
|
import (
|
||
|
_ "embed"
|
||
|
|
||
|
"github.com/charmbracelet/log"
|
||
|
"github.com/getlantern/systray"
|
||
|
"newty.dev/uofgcal/fetch"
|
||
|
)
|
||
|
|
||
|
//go:embed uofg.ico
|
||
|
var icon []byte
|
||
|
|
||
|
func OnReady() {
|
||
|
systray.SetTitle("UofG Sync") // mac+linux
|
||
|
systray.SetTooltip("UofG Sync")
|
||
|
systray.SetIcon(icon)
|
||
|
|
||
|
// todo: last synced
|
||
|
// todo: force sync
|
||
|
// todo: pause sync
|
||
|
// todo: options
|
||
|
|
||
|
// quit button
|
||
|
quit := systray.AddMenuItem("Quit", "Quit the application")
|
||
|
go func() {
|
||
|
<-quit.ClickedCh
|
||
|
systray.Quit()
|
||
|
}()
|
||
|
}
|
||
|
|
||
|
func OnExit() {
|
||
|
err := (*fetch.Scheduler).Shutdown()
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
}
|