theme

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: MIT, MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package theme is how the splash looks: the validated theme.yaml, and the drawing of a frame from the splash's state, damage included, with no KMS underneath so tests can render it.

Index

Constants

View Source
const BGRTDir = "/sys/firmware/acpi/bgrt"

BGRTDir is where Linux exposes the ACPI BGRT table.

View Source
const CapsLockHint = "Caps Lock is on"
View Source
const Frames = 36

Frames is how many steps one turn of the throbber takes.

Variables

This section is empty.

Functions

This section is empty.

Types

type BGRT

type BGRT struct {
	Image  image.Image
	Offset image.Point
}

BGRT is the logo the firmware left on screen: its image and where the firmware drew it, in the firmware's own pixels.

func LoadBGRT

func LoadBGRT(dir string) (*BGRT, error)

LoadBGRT reads the firmware's logo from dir. A machine without a BGRT table, or one whose status says the logo is no longer on screen, has none: nil and no error.

type Hints

type Hints struct {
	CapsLock bool
	Keymap   string
}
type Logo uint8

Logo is what the splash shows as its logo.

const (
	// it left one on screen, otherwise the lys logo.
	FirmwareLogo Logo = iota
	LysLogo
)

type LogoRaster

type LogoRaster struct {
	// contains filtered or unexported fields
}

LogoRaster is the lys logo rasterized for a scale.

func RasterizeLogo(scale int) (*LogoRaster, error)

RasterizeLogo draws the lys logo at scale, milliseconds of work that does not belong on the frame loop and needs no Renderer.

type Prompt

type Prompt struct {
	Kind  PromptKind
	Text  string
	Shown string
}

Prompt is the question on screen and what is shown of the answer typed so far: one bullet per character for a password, the text for a question.

type PromptKind

type PromptKind uint8

PromptKind is what a prompt asks for.

const (
	NoPrompt PromptKind = iota
	PasswordPrompt
	QuestionPrompt
)

The prompt kinds.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer draws frames from states with one theme. It is not safe for concurrent use.

func NewRenderer

func NewRenderer(t Theme, bgrt *BGRT) (*Renderer, error)

NewRenderer prepares drawing with t; bgrt is the firmware's logo, nil when it left none.

func (r *Renderer) AddLogo(l *LogoRaster)

AddLogo keeps a logo for the frames at its scale.

func (*Renderer) Draw

func (r *Renderer) Draw(f kms.Frame, scale int, prev *State, cur State) (kms.Damage, error)

Draw brings frame f, shown at scale, from prev to cur and returns the rectangles it changed. With prev nil the whole frame is drawn; otherwise only the pixels whose state differs are redrawn: the entry for a key typed, the text's extent for a message, the columns between two fills of a bar.

func (r *Renderer) NeedsLogo(scale int) bool

NeedsLogo says a first frame at scale would rasterize the logo.

func (*Renderer) PhasesToNextPicture

func (r *Renderer) PhasesToNextPicture(phase int) int

PhasesToNextPicture is how many phases from phase the throbber shows a different picture.

type State

type State struct {
	Hidden   bool
	Message  string
	Prompt   Prompt
	Hints    Hints
	Updating bool
	Booting  bool
	Progress protocol.Percent
	Phase    int
}

State is what the splash shows. Progress is the update's while Updating, and else the boot's while Booting.

func (State) CapsLockShown

func (s State) CapsLockShown() string

func (State) KeymapShown

func (s State) KeymapShown() string

type Theme

type Theme struct {
	Background render.Color
	Foreground render.Color
	Accent     render.Color
	Throbber   Throbber
	// Units shows the name of each unit systemd starts on the message line.
	Units       bool
	PromptHints bool
}

Theme is a validated theme.

func Default

func Default() Theme

Default is the theme embedded in the binary.

func Load

func Load(path string) (Theme, error)

Load reads the theme at path. A missing file is the default theme; a file that cannot be read or does not validate is an error naming the file and the field, returned with the default theme for the splash to fall back to.

func Parse

func Parse(file string, data []byte) (Theme, error)

Parse validates a theme.yaml read from file; a field it leaves out keeps the default theme's value.

type Throbber

type Throbber uint8

Throbber is the busy animation's style.

const (
	// Spinner is an arc turning around a faint ring.
	Spinner Throbber = iota
	// Dots is three dots lighting up in turn.
	Dots
)

Jump to

Keyboard shortcuts

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