Documentation
¶
Overview ¶
Package themes discovers, renders, and installs gowall theme templates.
Index ¶
- Variables
- func Apply(id string, data ThemeData) error
- func ApplyEmbedded(name, outputPath string, data ThemeData) error
- func ApplyTemplate(templatePath, outputPath string, data ThemeData) error
- func EnsureTemplatesInstalled() error
- func ParseTargetComment(templateContent string) (targetPath, body string, err error)
- func RenderEmbedded(name string, data ThemeData) (string, error)
- func RenderTemplate(raw string, data ThemeData) (string, error)
- func TemplateBodyForExecute(templateContent string) string
- func TemplateVariableHelp() string
- type BuiltinTemplate
- type Template
- type TemplateHeaders
- type ThemeData
Constants ¶
This section is empty.
Variables ¶
var BuiltinTemplates = []BuiltinTemplate{
{ID: "alacritty", EmbedPath: "alacritty.toml.tmpl", DefaultOutput: "$HOME/.config/alacritty/colors.toml"},
{ID: "polybar", EmbedPath: "polybar/colors.ini.tmpl", DefaultOutput: "$HOME/.config/polybar/colors.ini"},
{ID: "rofi", EmbedPath: "rofi/color.rasi.tmpl", DefaultOutput: "$HOME/.config/rofi/color.rasi"},
{ID: "bspwmrc", EmbedPath: "bspwmrc.tmpl", DefaultOutput: "$HOME/.config/bspwm/bspwmrc"},
{ID: "gtk", EmbedPath: "gtk.css.tmpl", DefaultOutput: "$HOME/.config/gtk-4.0/colors.css"},
{ID: "vscode", EmbedPath: "vscode.json.tmpl", DefaultOutput: "$HOME/.config/Code/User/settings.json"},
}
BuiltinTemplates is the registry of all embedded templates. Add new entries here and ensure the .tmpl file is included in the go:embed directive above.
Functions ¶
func Apply ¶
Apply renders the template identified by id from $HOME/.config/gowall/templates/ and writes the result to the target path declared in the template's # target: comment. ThemeData is required for rendering.
func ApplyEmbedded ¶
ApplyEmbedded renders a template embedded in the binary. name is the path inside the embed (e.g. "alacritty.toml.tmpl", "polybar/colors.ini.tmpl"). Templates are embedded in the binary; no external template files are required.
func ApplyTemplate ¶
ApplyTemplate renders a template from the filesystem (for tests or custom paths).
func EnsureTemplatesInstalled ¶
func EnsureTemplatesInstalled() error
EnsureTemplatesInstalled copies bundled templates to $HOME/.config/gowall/templates/ if that directory does not already exist. It is idempotent: if the dir exists, no-op.
func ParseTargetComment ¶
ParseTargetComment reads template headers and returns the target path and body. Returns an error if no "# target:" header is present.
func RenderEmbedded ¶
RenderEmbedded renders an embedded template to a string without writing to disk.
func RenderTemplate ¶
RenderTemplate renders a template from a raw string (e.g. a user-defined template loaded from disk) to a string without writing to disk.
func TemplateBodyForExecute ¶
TemplateBodyForExecute returns content suitable for text/template.Parse. All leading "# target:" and "# name:" header lines are stripped so they are not written to generated config files.
func TemplateVariableHelp ¶
func TemplateVariableHelp() string
TemplateVariableHelp returns documentation for template authors (variables available in .tmpl files).
Types ¶
type BuiltinTemplate ¶
type BuiltinTemplate struct {
ID string // e.g. "alacritty"
EmbedPath string // path in embed FS
DefaultOutput string // path with $HOME expanded (e.g. "$HOME/.config/alacritty/colors.toml")
}
BuiltinTemplate defines a built-in template (embedded in the binary).
func BuiltinByID ¶
func BuiltinByID(id string) *BuiltinTemplate
BuiltinByID returns the builtin template for id, or nil if not found.
type Template ¶
type Template struct {
ID string
SourcePath string // filesystem path to the .tmpl file
TargetPath string // expanded target path from # target: comment
IsBuiltin bool
}
Template describes a discovered template (either builtin or user-defined).
func DiscoverTemplates ¶
DiscoverTemplates reads all *.tmpl files from $HOME/.config/gowall/templates/ and returns a Template slice. Returns an empty slice (no error) if the directory does not exist.
type TemplateHeaders ¶
type TemplateHeaders struct {
Target string // expanded path from "# target: <path>"; empty if absent
Name string // display name from "# name: <name>"; empty if absent
Body string // template content after the header block
}
TemplateHeaders holds metadata parsed from the leading comment block of a template file.
func ParseTemplateHeaders ¶
func ParseTemplateHeaders(content string) TemplateHeaders
ParseTemplateHeaders scans leading lines of content for "# target: " and "# name: " comments in any order, stopping at the first line that does not match a known header. All matched header lines are stripped from Body.
type ThemeData ¶
type ThemeData struct {
Background string // hex without # (e.g. "1a1a1a")
Foreground string // hex
Ansi []string // 16 elements: [0]=black .. [7]=white, [8]=bright black .. [15]=bright white
Tones []string // 16 steps dark→light (from image palette)
TonesFromANSI []string // 16 steps from retoned ANSI; only non-nil when -retone-ansi (or -ansi-colors) was used
}
ThemeData holds all color values rendered into theme templates.
func LoadColorReferenceFile ¶
LoadColorReferenceFile reads and parses a color reference file.
func ParseColorReference ¶
ParseColorReference parses a Gowall Color Reference document (same format as exportColorReference writes). Lines starting with # are comments except for assignment lines that begin with a dot. Hex may include or omit a leading #.