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
|
package theme
import (
"os/exec"
"runtime"
"strings"
)
// Detect returns "flexoki-dark" or "flexoki-light" from the OS appearance. On
// non-darwin platforms it returns dark. On macOS it reads the global
// AppleInterfaceStyle key (unset in Light mode → empty output → light).
func Detect() string {
if runtime.GOOS != "darwin" {
return "flexoki-dark"
}
out, _ := exec.Command("defaults", "read", "-g", "AppleInterfaceStyle").Output()
return detectFrom(string(out))
}
// detectFrom parses the raw `defaults read -g AppleInterfaceStyle` output.
func detectFrom(raw string) string {
if strings.Contains(raw, "Dark") {
return "flexoki-dark"
}
return "flexoki-light"
}
|