macos.go

 1package theme
 2
 3import (
 4	"runtime"
 5
 6	"charm.land/lipgloss/v2"
 7	"github.com/floatpane/matcha/clib/macos"
 8)
 9
10// SyncWithMacOS updates the 'Native' theme with current macOS system appearance.
11func SyncWithMacOS() error {
12	if runtime.GOOS != "darwin" {
13		return nil
14	}
15
16	appearance, err := macos.GetAppearance()
17	if err != nil {
18		return err
19	}
20
21	// Update Native theme
22	Native.Accent = lipgloss.Color(appearance.AccentColor)
23	Native.Directory = lipgloss.Color(appearance.AccentColor)
24
25	if appearance.DarkMode {
26		// Dark mode specifics if needed
27		Native.AccentText = lipgloss.Color("#FFFDF5")
28		Native.Contrast = lipgloss.Color("#000000")
29	} else {
30		// Light mode specifics
31		Native.AccentText = lipgloss.Color("#000000")
32		Native.Contrast = lipgloss.Color("#FFFFFF")
33		Native.Secondary = lipgloss.Color("240")
34	}
35
36	// If the active theme is 'Native', update it immediately
37	if ActiveTheme.Name == "Native" {
38		ActiveTheme = Native
39	}
40
41	return nil
42}