-
-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathicondarwin.go
52 lines (43 loc) · 1018 Bytes
/
icondarwin.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
//go:build darwin
package icon
import (
_ "embed" // import embed to embed the icon
"os/exec"
"strings"
)
// isDarkMode will return if the system is in darkmode
func isDarkMode() bool {
cmd := exec.Command("defaults", "read", "-g", "AppleInterfaceStyle")
output, _ := cmd.Output()
return strings.Contains(string(output), "Dark")
}
// GetIcon will return the icon
func GetIcon() []byte {
if isDarkMode() {
return data
}
return dataLight
}
// GetIconHiber will return the hibernated icon
func GetIconHiber() []byte {
if isDarkMode() {
return dataDarkHibernate
}
return dataLightHibernate
}
// dataLight represents the icon
//
//go:embed icon_mac_light.png
var dataLight []byte
// dataLightHibernate represents the light icon hibernated
//
//go:embed icon_mac_light_hiber.png
var dataLightHibernate []byte
// data represents the icon
//
//go:embed icon_mac.png
var data []byte
// dataDarkHibernate represents the dark icon hibernated
//
//go:embed icon_mac_hiber.png
var dataDarkHibernate []byte