config

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Opaque

func Opaque(c color.RGBA) color.RGBA

Opaque returns c with its alpha forced fully opaque. The bar background may be translucent so the wallpaper shows through the bar, but where that same colour is reused as a popup surface or as contrasting text it must stay solid — otherwise the popup renders invisible.

func ParseHexOr

func ParseHexOr(hex string, fallback color.RGBA) color.RGBA

ParseHexOr parses hex into an RGBA, or returns fallback if hex is empty. Used to overlay per-module colour overrides onto the global palette.

Types

type AudioCfg

type AudioCfg struct {
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type Base16

type Base16 struct {
	Base00, Base01, Base02, Base03 string
	Base04, Base05, Base06, Base07 string
	Base08, Base09, Base0A, Base0B string
	Base0C, Base0D, Base0E, Base0F string
}

Base16 is a resolved base16 palette: the sixteen base00..base0F colours, each stored as a "#rrggbb" string. Derived role colours come out of Colors().

func LoadBase16

func LoadBase16(nameOrPath string) (Base16, error)

LoadBase16 resolves a base16 scheme from a name or a file path:

  • A value that looks like a path (contains a separator, has a .yaml/.yml extension, or starts with "~", "." or "/") is read from disk; a leading "~/" expands to $HOME.
  • Otherwise it is a scheme NAME, resolved to ~/.config/wlbar/themes/<name>.yaml. wlbar ships no schemes itself — grab one from https://github.com/tinted-theming/schemes (or the archived base16-schemes) and drop the .yaml in that directory.

The parser accepts both the legacy flat base16 format (top-level `base00: "282828"`, hex without "#", optional trailing comments) and the newer tinted-theming format (`palette:` block, `base00: "#282828"`).

func (Base16) Colors

func (b Base16) Colors() Colors

Colors maps a base16 palette onto wlbar's role-based Colors using an opinionated, deliberately colourful assignment: rather than collapsing every accent onto a single hue, it spreads the scheme's accent colours across distinct UI roles so the scheme's identity actually shows.

background  base00            foreground  base05
accent      base0D (blue)     muted       base03 (gray)
focused_bg  base0D (blue)     focused_fg  base00 (dark text on blue)
occupied_bg base02            occupied_fg base05
urgent      base08 (red)      urgent_bg   base08 (red)
urgent_fg   base00 (dark)     low_fg      base09 (orange)

Pill backgrounds ([pills]) are deliberately left untouched: they default to empty (no pill drawn), so seeding them would force a pill look on every themed config. Set them yourself in [pills] if you want one.

func (Base16) ModuleColors

func (b Base16) ModuleColors() map[string]string

ModuleColors assigns each module a default text colour drawn from the scheme's eight accents (base08..base0F), so a themed bar comes out colourful without a single per-module fg. The assignment leans on conventional hues (cpu green, memory yellow, temperature cyan, disk orange) and is arranged so neighbouring modules in a typical right-hand group land on different accents.

clock and title are deliberately absent: they fall back to the global foreground so the primary clock/title text stays neutral rather than tinted. Any [<module>] fg or [module_colors] entry overrides its module here.

type BatteryCfg

type BatteryCfg struct {
	Name   string `toml:"name"`
	PollMs int    `toml:"poll_ms"`
	LowAt  int    `toml:"low_at"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type BluetoothCfg

type BluetoothCfg struct {
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type CPUCfg

type CPUCfg struct {
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type ClockCfg

type ClockCfg struct {
	Format string `toml:"format"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type Colors

type Colors struct {
	Background string `toml:"background"`
	// BackgroundOpacity, when set (0.0 fully transparent … 1.0 opaque),
	// overrides just the ALPHA of the bar background and leaves the colour
	// itself to the scheme (base00) or the background hex. This is the clean
	// way to get a translucent bar under a theme: you no longer have to
	// hand-write a whole "#rrggbbaa" just to dial transparency. Unset (key
	// absent) keeps the background's own alpha — opaque unless its hex already
	// carried one.
	BackgroundOpacity float64 `toml:"background_opacity"`
	Foreground        string  `toml:"foreground"`
	Accent            string  `toml:"accent"`
	Muted             string  `toml:"muted"`
	Urgent            string  `toml:"urgent"`
	FocusedBG         string  `toml:"focused_bg"`
	OccupiedBG        string  `toml:"occupied_bg"`
	UrgentBG          string  `toml:"urgent_bg"`
	UrgentFG          string  `toml:"urgent_fg"`
	FocusedFG         string  `toml:"focused_fg"`
	OccupiedFG        string  `toml:"occupied_fg"`
	LowFG             string  `toml:"low_fg"`
}

func (Colors) Resolve

func (c Colors) Resolve() (ParsedColors, error)

Resolve parses every Colors hex string into RGBA values.

type Config

type Config struct {
	Height     int32  `toml:"height"`
	Font       Font   `toml:"font"`
	Theme      Theme  `toml:"theme"`
	Colors     Colors `toml:"colors"`
	SegmentGap int32  `toml:"segment_gap"`
	// HideIcons drops the icon glyph from any segment that also carries text,
	// turning the bar into a plain-text status line (DWM / dwmblocks style).
	// Icon-only segments such as mpris transport buttons or rivertags dots
	// are kept — they're the content, not redundant labels.
	HideIcons bool `toml:"hide_icons"`

	// Elastic lists, in priority order, the modules whose text the bar
	// truncates with an ellipsis when the left/center/right groups would
	// overflow the screen width. The first name yields its width first (down
	// to a bare "…") before the next is touched. Empty disables the
	// width-aware shrink. Defaults to ["title", "nirititle", "mpris"] — the
	// longest, most variable text modules (title/nirititle never coexist, so
	// listing both is harmless).
	Elastic []string `toml:"elastic"`

	Layout      Layout         `toml:"layout"`
	Outputs     OutputFilter   `toml:"outputs"`
	Pills       PillsCfg       `toml:"pills"`
	Popup       PopupCfg       `toml:"popup"`
	Pill        []PillGroupCfg `toml:"pill"`
	Clock       ClockCfg       `toml:"clock"`
	Title       TitleCfg       `toml:"title"`
	Battery     BatteryCfg     `toml:"battery"`
	Network     NetworkCfg     `toml:"network"`
	Audio       AudioCfg       `toml:"audio"`
	Bluetooth   BluetoothCfg   `toml:"bluetooth"`
	Tags        TagsCfg        `toml:"tags"`
	CPU         CPUCfg         `toml:"cpu"`
	Memory      MemoryCfg      `toml:"memory"`
	Temperature TemperatureCfg `toml:"temperature"`
	Disk        DiskCfg        `toml:"disk"`
	VPN         VPNCfg         `toml:"vpn"`
	Pacman      PacmanCfg      `toml:"pacman"`
	MPRIS       MPRISCfg       `toml:"mpris"`

	// ModuleColors is a flat shorthand: instead of a [<module>] section
	// per module just to set "fg = ...", set them all in one place:
	//
	//   [module_colors]
	//   cpu = "#e5c890"
	//   memory = "#ee994a"
	//
	// Equivalent to writing [cpu] fg = "#e5c890". A per-module section's
	// fg always wins when both are set, so this is a no-friction add for
	// the common case (set a colour, nothing else) without taking power
	// away from the verbose form.
	ModuleColors map[string]string `toml:"module_colors"`
}

Config is the on-disk schema for $XDG_CONFIG_HOME/wlbar/config.toml. Defaults are filled in by Default() before TOML overlays its values.

func Default

func Default() Config

Default returns a Config with sensible values; TOML overlay only changes what's explicitly set.

func Load

func Load(path string) (Config, []string, error)

Load reads TOML at path (or the XDG default if empty), overlaying the defaults. Missing files are not errors; we run with defaults in that case. Returns the parsed config plus any unknown TOML keys (typos / removed settings) so callers can warn — typo'd keys would otherwise be silently ignored, which is the worst kind of UX.

type DiskCfg

type DiskCfg struct {
	Path   string `toml:"path"`
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type Font

type Font struct {
	Primary string `toml:"primary"`
	// PrimaryBold is an optional path / fontconfig name for the bold weight
	// of the primary face. When set, modules with bold = true rasterise via
	// this face. When empty, bold falls back to synthetic double-draw (same
	// glyph blitted twice with a 1-pixel horizontal offset).
	PrimaryBold string `toml:"primary_bold"`
	// Icons names the font face used to rasterise the module icon glyphs
	// (clock, battery, network, …). Defaults to "Symbols Nerd Font" — a
	// face dedicated to icon codepoints, designed to be used alongside any
	// regular text font. Either an absolute font path or a fontconfig name
	// resolvable by fc-match.
	Icons  string  `toml:"icons"`
	SizePx float64 `toml:"size_px"`
	// Bold sets the DEFAULT text weight for every module: true (the default)
	// draws all modules bold, false draws them regular. Override per module
	// with `[<module>] bold = false/true`. Bold uses primary_bold when set,
	// otherwise a synthetic double-blit.
	Bold bool `toml:"bold"`
	// DPIAware only affects compositors that do NOT expose surface scale to
	// clients (notably River). On those, when true, the bar falls back to the
	// monitor's physical DPI (≥144 → 2×) to pick a HiDPI size. On compositors
	// that DO scale (niri, sway, …) the bar always honours the surface's real
	// (fractional) scale via wp_fractional_scale + wp_viewporter and renders
	// pixel-perfect, regardless of this flag.
	DPIAware bool `toml:"dpi_aware"`
	// DPIScale: manual override of the render scale. 0 means auto (the
	// compositor's fractional/integer surface scale, or the DPIAware fallback).
	// A non-zero value LOCKS the scale and ignores the compositor's preferred
	// scale — useful to force an in-between size like 1.5.
	DPIScale float64 `toml:"dpi_scale"`
}

type Layout

type Layout struct {
	Left   []string `toml:"left"`
	Center []string `toml:"center"`
	Right  []string `toml:"right"`
}

type MPRISCfg

type MPRISCfg struct {
	PollMs       int `toml:"poll_ms"`
	MaxTitleRune int `toml:"max_title_runes"`
	// Players is an optional priority list of MPRIS short-names
	// (e.g. "spotify", "mpv"). When non-empty, the first matching
	// Playing player wins; ties fall back to list order. Matched on
	// the suffix after "org.mpris.MediaPlayer2."; "spotify" also matches
	// per-instance names like "spotify.instance123".
	Players []string `toml:"players"`
	FG      string   `toml:"fg"`
	BG      string   `toml:"bg"`
	Bold    bool     `toml:"bold"`
}

type MemoryCfg

type MemoryCfg struct {
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type NetworkCfg

type NetworkCfg struct {
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
	// MaxLabelRunes caps the SSID / IPv4 length (0 = no cap). A static upper
	// bound so a very long SSID can't dominate the bar; the elastic shrink
	// doesn't touch network.
	MaxLabelRunes int `toml:"max_label_runes"`
}

type OutputFilter

type OutputFilter struct {
	Include []string `toml:"include"`
	Exclude []string `toml:"exclude"`
}

func (OutputFilter) Allow

func (f OutputFilter) Allow(name, description string) bool

Allow decides whether to attach a bar to a given (name, description). Empty filters allow everything.

type PacmanCfg

type PacmanCfg struct {
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

type ParsedColors

type ParsedColors struct {
	Background color.RGBA
	Foreground color.RGBA
	Accent     color.RGBA
	Muted      color.RGBA
	Urgent     color.RGBA
	FocusedBG  color.RGBA
	OccupiedBG color.RGBA
	UrgentBG   color.RGBA
	UrgentFG   color.RGBA
	FocusedFG  color.RGBA
	OccupiedFG color.RGBA
	LowFG      color.RGBA
}

ParsedColors holds resolved RGBA values from the string-form Colors.

type PillGroupCfg

type PillGroupCfg struct {
	Modules []string `toml:"modules"`
	BG      string   `toml:"bg"`
}

PillGroupCfg is one rounded pill declared as a [[pill]] table. modules lists the module names (matching [layout]) it wraps; they must be contiguous and on the same side. Any [[pill]] entry disables the per-side [pills] *_bg colours, giving full control over which modules share a pill.

type PillsCfg

type PillsCfg struct {
	Radius   int32  `toml:"radius"`
	MarginX  int32  `toml:"margin_x"`
	MarginY  int32  `toml:"margin_y"`
	PadX     int32  `toml:"pad_x"`
	LeftBG   string `toml:"left_bg"`
	CenterBG string `toml:"center_bg"`
	RightBG  string `toml:"right_bg"`
	// Opacity, when set (0.0 fully transparent … 1.0 opaque), overrides just
	// the ALPHA of every configured pill background — the per-side *_bg above
	// and any [[pill]] bg — leaving each pill's colour to the scheme or its own
	// hex. This is the pill counterpart of [colors] background_opacity: the
	// clean way to dial translucent pills (e.g. so a transparent bar shows the
	// wallpaper straight through them) without hand-writing "#rrggbbaa". Unset
	// (key absent) keeps each pill colour's own alpha. A blank pill colour stays
	// blank — opacity never conjures a pill where none was configured.
	Opacity float64 `toml:"opacity"`
}

PillsCfg describes the optional rounded-rectangle backgrounds drawn behind each side group. A side gets a pill when its *_bg colour is set; geometry (radius, margins, padding) is shared. Sizes are in logical pixels and are scaled with the rest of the bar on HiDPI.

type PopupCfg

type PopupCfg struct {
	Radius int32 `toml:"radius"`
}

PopupCfg styles the hover popups (the clock calendar and module tooltips). Radius rounds their corners (in logical pixels, scaled with the popup); 0 keeps the square box. The corners outside the radius become transparent so the popup reads as a floating rounded card.

type TagsCfg

type TagsCfg struct {
	N             int    `toml:"count"`
	OccupiedGlyph string `toml:"occupied_glyph"`
	PaddingPx     int32  `toml:"padding_px"`
	// Dots renders each tag as a centred filled circle coloured by state
	// instead of a numbered cell.
	Dots bool `toml:"dots"`
	// Dot colours (used only in Dots mode). The dot itself is coloured by
	// occupancy — DotEmpty for an empty tag, DotOccupied for one with windows,
	// DotUrgent for an urgent one. The focused tag keeps that colour but is
	// drawn as a larger dot. Empty values fall back to the palette.
	DotEmpty    string `toml:"dot_empty"`
	DotOccupied string `toml:"dot_occupied"`
	DotUrgent   string `toml:"dot_urgent"`
	// Bold draws the numbered cells in the bold variant of the primary
	// font (or synthetic bold when no bold face is configured). No effect
	// in Dots mode.
	Bold bool `toml:"bold"`
}

type TemperatureCfg

type TemperatureCfg struct {
	HwmonPath  string `toml:"hwmon_path"`
	Critical   int    `toml:"critical"`
	PollMs     int    `toml:"poll_ms"`
	FG         string `toml:"fg"`
	BG         string `toml:"bg"`
	CriticalFG string `toml:"critical_fg"`
	Bold       bool   `toml:"bold"`
}

type Theme

type Theme struct {
	Base16 string `toml:"base16"`
}

Theme seeds the whole palette from a base16 colour scheme, so you don't have to hand-tune every role under [colors]. See base16.go for the slot→role mapping; any key you set under [colors] still overrides the scheme for that one role.

type TitleCfg

type TitleCfg struct {
	MaxRunes int    `toml:"max_runes"`
	FG       string `toml:"fg"`
	BG       string `toml:"bg"`
	Bold     bool   `toml:"bold"`
}

type VPNCfg

type VPNCfg struct {
	Iface  string `toml:"iface"`
	Label  string `toml:"label"`
	PollMs int    `toml:"poll_ms"`
	FG     string `toml:"fg"`
	BG     string `toml:"bg"`
	Bold   bool   `toml:"bold"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL