Documentation
¶
Overview ¶
Package theme resolves the app's color palette. The palette tracks the desktop's live theme when one is available (~/.config/aliasos/current/theme/colors.toml, aliasos's "Aether" theme format), and can be further overridden by a user config file at $XDG_CONFIG_HOME/notch/theme.conf (falling back to ~/.config/notch/theme.conf) — so notch recolors itself when the desktop theme changes, and a notch-specific tweak always wins over both. See README.md for the theme.conf file format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Colors = load()
Colors is the active palette. It's resolved once here, at package-init time — before any importing package's own package-level vars (which copy out of Colors, e.g. views.cPrimary = theme.Colors.Primary) are initialized, per Go's guarantee that an imported package finishes initializing before the importing package's own initializers run.
var Default = Palette{
Primary: "#91B0DE",
Accent: "#9DC6E9",
Success: "#99C2ED",
Warning: "#A4CBF7",
Danger: "#C79EA9",
Text: "#C2D9E9",
Dim: "#B7D2E5",
Subtle: "#899EAC",
Bg: "#0D171F",
BgAlt: "#252E35",
Border: "#5F6468",
Highlight: "#AFCFFF",
}
Default is the fallback palette: used as-is on a machine with no aliasos theme file, and as the base for any field an aliasos theme doesn't define. Matches the user's current aliasos "aether" theme (pastel blues throughout, dusty rose/mauve reserved for danger).
Functions ¶
func CheckReload ¶
func CheckReload() bool
CheckReload re-reads the aliasos OS theme and/or the notch theme.conf file if either has changed since the last successful load (by mtime), or falls back to Default for a source that's been removed since it was last present. Returns true if Colors changed. Cheap to call frequently: the common case is one or two os.Stat calls with no reload.
func Watch ¶
func Watch() <-chan struct{}
Watch starts watching the filesystem for changes to the OS theme or the notch theme.conf override, and returns a channel that receives a value shortly after either changes — a fast trigger for CheckReload, so the UI doesn't have to wait for its next poll tick to notice a theme switch.
It watches the *parent* directories rather than the files themselves: aliasos applies a new theme by rm-rf'ing and mv'ing in the whole current/theme directory rather than editing colors.toml in place, which would invalidate a watch on the file itself (inotify watches follow the inode, not the path — once the watched file is removed, no further events arrive at that path even though a new file lands there moments later).
Returns nil if no watchable directory could be resolved or the OS watcher failed to start; callers should treat a nil channel as one that never fires — CheckReload's existing poll loop remains the fallback.
Types ¶
type Palette ¶
type Palette struct {
Primary lipgloss.Color
Accent lipgloss.Color
Success lipgloss.Color
Warning lipgloss.Color
Danger lipgloss.Color
Text lipgloss.Color
Dim lipgloss.Color
Subtle lipgloss.Color
Bg lipgloss.Color
BgAlt lipgloss.Color
Border lipgloss.Color
Highlight lipgloss.Color
}
Palette holds every themable color. Field names match the theme.conf file's keys (lowercased, underscores for multi-word names — see fieldPtr).
func LoadFrom ¶
LoadFrom reads a notch theme.conf file at path and returns Default with any valid overrides applied. A missing or unreadable file returns Default unchanged; individual malformed lines are skipped rather than aborting the whole file. It does not consult the aliasos OS theme — use this to inspect a theme.conf file in isolation (as the tests do); the live Colors value goes through load/CheckReload instead, which layer OS-theme detection in underneath.