Skip to content

Commit 3e248b5

Browse files
committed
fix detection of dark mode on MacOS
1 parent a5861be commit 3e248b5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

icon/icondarwin.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,18 @@ package icon
55
import (
66
_ "embed" // import embed to embed the icon
77
"os/exec"
8-
"strings"
98
)
109

1110
// isDarkMode will return if the system is in darkmode
11+
// see https://gist.github.com/jerblack/869a303d1a604171bf8f00bbbefa59c2
1212
func isDarkMode() bool {
1313
cmd := exec.Command("defaults", "read", "-g", "AppleInterfaceStyle")
14-
output, _ := cmd.Output()
15-
return strings.Contains(string(output), "Dark")
14+
if err := cmd.Run(); err != nil {
15+
if _, ok := err.(*exec.ExitError); ok {
16+
return false
17+
}
18+
}
19+
return true
1620
}
1721

1822
// GetIcon will return the icon

0 commit comments

Comments
 (0)