Only do systray stuff on windows
This commit is contained in:
parent
9294ca9e33
commit
d8b16674dd
40
dau.go
40
dau.go
@ -21,7 +21,6 @@ import (
|
|||||||
daulog "github.com/tardisx/discord-auto-upload/log"
|
daulog "github.com/tardisx/discord-auto-upload/log"
|
||||||
"github.com/tardisx/discord-auto-upload/upload"
|
"github.com/tardisx/discord-auto-upload/upload"
|
||||||
|
|
||||||
"github.com/getlantern/systray"
|
|
||||||
"github.com/skratchdot/open-golang/open"
|
"github.com/skratchdot/open-golang/open"
|
||||||
|
|
||||||
// "github.com/tardisx/discord-auto-upload/upload"
|
// "github.com/tardisx/discord-auto-upload/upload"
|
||||||
@ -83,7 +82,7 @@ func main() {
|
|||||||
startWatchers(config, up, configChanged)
|
startWatchers(config, up, configChanged)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
systray.Run(func() { onReady(config) }, onExit)
|
mainloop(config)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,43 +206,6 @@ func parseOptions() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func onReady(c *config.ConfigService) {
|
|
||||||
|
|
||||||
systray.SetIcon(appIcon)
|
|
||||||
//systray.SetTitle("DAU")
|
|
||||||
systray.SetTooltip(fmt.Sprintf("discord-auto-upload %s", version.CurrentVersion))
|
|
||||||
openApp := systray.AddMenuItem("Open", "Open in web browser")
|
|
||||||
gh := systray.AddMenuItem("Github", "Open project page")
|
|
||||||
ghr := systray.AddMenuItem("Release Notes", "Open project release notes")
|
|
||||||
quit := systray.AddMenuItem("Quit", "Quit")
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
<-quit.ClickedCh
|
|
||||||
systray.Quit()
|
|
||||||
}()
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-openApp.ClickedCh:
|
|
||||||
openWebBrowser(c.Config.Port)
|
|
||||||
case <-gh.ClickedCh:
|
|
||||||
open.Start("https://github.com/tardisx/discord-auto-upload")
|
|
||||||
case <-ghr.ClickedCh:
|
|
||||||
open.Start(fmt.Sprintf("https://github.com/tardisx/discord-auto-upload/releases/tag/%s", version.CurrentVersion))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Sets the icon of a menu item. Only available on Mac and Windows.
|
|
||||||
// mQuit.SetIcon(icon.Data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func onExit() {
|
|
||||||
// clean up here
|
|
||||||
daulog.Info("quitting on user request")
|
|
||||||
}
|
|
||||||
|
|
||||||
func openWebBrowser(port int) {
|
func openWebBrowser(port int) {
|
||||||
address := fmt.Sprintf("http://localhost:%d", port)
|
address := fmt.Sprintf("http://localhost:%d", port)
|
||||||
open.Start(address)
|
open.Start(address)
|
||||||
|
11
dau_nonwindows.go
Normal file
11
dau_nonwindows.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/tardisx/discord-auto-upload/config"
|
||||||
|
|
||||||
|
func mainloop(c *config.ConfigService) {
|
||||||
|
|
||||||
|
ch := make(chan bool)
|
||||||
|
<-ch
|
||||||
|
}
|
51
dau_windows.go
Normal file
51
dau_windows.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/getlantern/systray"
|
||||||
|
"github.com/skratchdot/open-golang/open"
|
||||||
|
"github.com/tardisx/discord-auto-upload/config"
|
||||||
|
daulog "github.com/tardisx/discord-auto-upload/log"
|
||||||
|
"github.com/tardisx/discord-auto-upload/version"
|
||||||
|
)
|
||||||
|
|
||||||
|
func mainloop(c *config.ConfigService) {
|
||||||
|
systray.Run(func() { onReady(c) }, onExit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func onReady(c *config.ConfigService) {
|
||||||
|
|
||||||
|
systray.SetIcon(appIcon)
|
||||||
|
//systray.SetTitle("DAU")
|
||||||
|
systray.SetTooltip(fmt.Sprintf("discord-auto-upload %s", version.CurrentVersion))
|
||||||
|
openApp := systray.AddMenuItem("Open", "Open in web browser")
|
||||||
|
gh := systray.AddMenuItem("Github", "Open project page")
|
||||||
|
ghr := systray.AddMenuItem("Release Notes", "Open project release notes")
|
||||||
|
quit := systray.AddMenuItem("Quit", "Quit")
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
<-quit.ClickedCh
|
||||||
|
systray.Quit()
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-openApp.ClickedCh:
|
||||||
|
openWebBrowser(c.Config.Port)
|
||||||
|
case <-gh.ClickedCh:
|
||||||
|
open.Start("https://github.com/tardisx/discord-auto-upload")
|
||||||
|
case <-ghr.ClickedCh:
|
||||||
|
open.Start(fmt.Sprintf("https://github.com/tardisx/discord-auto-upload/releases/tag/%s", version.CurrentVersion))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Sets the icon of a menu item. Only available on Mac and Windows.
|
||||||
|
// mQuit.SetIcon(icon.Data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func onExit() {
|
||||||
|
// clean up here
|
||||||
|
daulog.Info("quitting on user request")
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user