-
Notifications
You must be signed in to change notification settings - Fork 0
/
systray_linux.go
69 lines (62 loc) · 1.8 KB
/
systray_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"log"
"strings"
"time"
"fyne.io/systray"
"github.com/atotto/clipboard"
"i2pgit.org/idk/railroad/configuration"
"i2pgit.org/idk/railroad/icon"
)
func onReady() {
systray.SetIcon(icon.Data)
systray.SetTitle("Railroad Blog")
systray.SetTooltip("Blog is running on I2P: http://" + host)
mShowUrl := systray.AddMenuItem("Copy Address", "copy blog address to clipboard")
mEditUrl := systray.AddMenuItem("Edit your blog", "Edit your blog in it's own webview")
if strings.HasSuffix(configuration.Config().HttpsUrl, "i2p") {
if !strings.HasSuffix(configuration.Config().HttpsUrl, "b32.i2p") {
mCopyUrl := systray.AddMenuItem("Copy blog address helper", "copy blog addresshelper to clipboard")
go func() {
<-mCopyUrl.ClickedCh
log.Println("Requesting copy short address helper:", configuration.Config().HttpsUrl+"/i2paddresshelper="+host)
clipboard.WriteAll(configuration.Config().HttpsUrl + "/?i2paddresshelper=" + host)
log.Println("Finished copy short address helper")
}()
}
}
mQuit := systray.AddMenuItem("Quit", "Quit the whole app")
// Sets the icon of a menu item. Only available on Mac and Windows.
mQuit.SetIcon(icon.Data)
for {
go func() {
<-mQuit.ClickedCh
log.Println("Requesting quit")
systray.Quit()
log.Println("Finished quitting")
}()
time.Sleep(time.Second)
go func() {
<-mEditUrl.ClickedCh
err := LaunchView()
if err != nil {
log.Fatal(err)
}
}()
time.Sleep(time.Second)
go func() {
<-mShowUrl.ClickedCh
log.Println("Waiting for password = ", passStat())
log.Println("Requesting copy base32", host)
clipboard.WriteAll("http://" + host)
log.Println("Finished copy base32")
}()
time.Sleep(time.Second * 3)
}
}
func onExit() {
// clean up here
}
func RunSystray() {
systray.Run(onReady, onExit)
}