Skip to content

Commit 8d40d95

Browse files
committed
add: icon switch demo fix: systray.SetIcon #7
1 parent 19fda2c commit 8d40d95

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

example/main.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"io/ioutil"
88
"os"
99
"path/filepath"
10+
"runtime"
1011
"strings"
1112
"time"
1213
)
@@ -135,8 +136,12 @@ func onReady() {
135136
wd = strings.Replace(wd, "example", "", -1)
136137
wd = filepath.Join(wd, "icon")
137138
fmt.Println("wd", wd) // /to/icon/path/icon.png, logo.png
138-
icoData, _ := ioutil.ReadFile(filepath.Join(wd, "icon.png"))
139-
logoData, _ := ioutil.ReadFile(filepath.Join(wd, "logo.png"))
139+
var ext = ".png"
140+
if runtime.GOOS == "windows" {
141+
ext = ".ico" // windows .ico
142+
}
143+
icoData, _ := ioutil.ReadFile(filepath.Join(wd, "icon"+ext))
144+
logoData, _ := ioutil.ReadFile(filepath.Join(wd, "logo"+ext))
140145
for true {
141146
time.Sleep(time.Second * 1)
142147
b = !b

icon/icon.ico

32.2 KB
Binary file not shown.

icon/logo.ico

4.19 KB
Binary file not shown.

0 commit comments

Comments
 (0)