Skip to content

Commit 54e403c

Browse files
committed
Fixed bugs on win
1 parent ae94b28 commit 54e403c

File tree

5 files changed

+271
-134
lines changed

5 files changed

+271
-134
lines changed

example/main.go

+19-18
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ func main() {
1313
}
1414

1515
tray := systray.New(os.Args[1], os.Args[2], 6333)
16-
go func() {
17-
err := tray.Run()
18-
if err != nil {
19-
println(err.Error())
20-
}
21-
}()
22-
2316
tray.OnClick(func() {
2417
println("clicked")
2518
})
@@ -28,22 +21,30 @@ func main() {
2821
println(err.Error())
2922
}
3023

31-
reader := bufio.NewReader(os.Stdin)
32-
for {
33-
println("Input icon file name:")
34-
print(">> ")
35-
data, _, _ := reader.ReadLine()
36-
line := string(data)
37-
if len(line) == 0 {
38-
break;
24+
go func() {
25+
reader := bufio.NewReader(os.Stdin)
26+
for {
27+
println("Input icon file name:")
28+
print(">> ")
29+
data, _, _ := reader.ReadLine()
30+
line := string(data)
31+
if len(line) == 0 {
32+
break
33+
}
34+
err := tray.Show(line, line)
35+
if err != nil {
36+
println(err.Error())
37+
}
3938
}
40-
err := tray.Show(line, line)
39+
40+
err = tray.Stop()
4141
if err != nil {
4242
println(err.Error())
4343
}
44-
}
44+
os.Exit(0)
45+
}()
4546

46-
err = tray.Stop()
47+
err = tray.Run()
4748
if err != nil {
4849
println(err.Error())
4950
}

tray.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ func New(iconPath string, clientPath string, port int) *Systray {
55
}
66

77
type Systray struct {
8-
_Systray
8+
*_Systray
99
}

tray_darwin.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package systray
22

3-
func _NewSystray(iconPath string, clientPath string, port int) _Systray {
4-
return _Systray{_NewSystraySvr(iconPath, clientPath + "/systray.app/Contents/MacOS/systray", port)}
3+
func _NewSystray(iconPath string, clientPath string, port int) *_Systray {
4+
return &_Systray{_NewSystraySvr(iconPath, clientPath + "/systray.app/Contents/MacOS/systray", port)}
55
}
66

77
type _Systray struct {

tray_linux.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package systray
22

3-
func _NewSystray(iconPath string, clientPath string, port int) _Systray {
4-
return _Systray{_NewSystraySvr(iconPath, clientPath, port)}
3+
func _NewSystray(iconPath string, clientPath string, port int) *_Systray {
4+
return &_Systray{_NewSystraySvr(iconPath, clientPath, port)}
55
}
66

77
type _Systray struct {

0 commit comments

Comments
 (0)