Documentation
¶
Overview ¶
Package wmconfig reads and edits lys-wm's config file. Edits touch only the bytes of the value they change, so comments, blank lines, key order and keys this program does not know survive, and each edit is held to what it meant by parsing the result before anything is written.
Index ¶
- Constants
- func ApplyEdit(src []byte, e Edit) ([]byte, error)
- func Exec(ctx context.Context, argv ...string) ([]byte, error)
- func Installed() bool
- func Lookup(tree map[string]any, path []string) (any, bool)
- func Merge(base, over map[string]any) map[string]any
- func Overridden(over map[string]any, path []string) bool
- func Tree(data []byte) (map[string]any, error)
- type Action
- type Edit
- type Field
- type File
- func (f *File) Apply(edits []Edit) (Reload, error)
- func (f *File) BuiltIn() ([]byte, error)
- func (f *File) Check(edits []Edit) error
- func (f *File) Overrides() (map[string]any, error)
- func (f *File) Path() string
- func (f *File) Read() (map[string]any, bool, error)
- func (f *File) ResetAll() (Reload, error)
- func (f *File) Runtime() string
- func (f *File) Schema() (*Schema, error)
- func (f *File) Writable() error
- type Kind
- type ReadOnlyError
- type RejectedError
- type Reload
- type ReloadError
- type Runner
- type Schema
- type ToolError
Constants ¶
const Each = "[]"
Each is the path segment naming every item of a list or every value of a mapping, as in outputs.[].scale.
Variables ¶
This section is empty.
Functions ¶
func ApplyEdit ¶
ApplyEdit is src with the edit made, or an error naming the line of what it cannot safely change; src is never partly edited.
func Installed ¶
func Installed() bool
Installed reports whether lys-wm is on the path. Without it nothing can check a change, so there is nothing to offer.
Types ¶
type Field ¶
type Field struct {
Kind Kind
Format string
// Variants are the values an Enum takes: strings and booleans, as the file
// writes them.
Variants []any
Min, Max float64
// MinItems and MaxItems bound how many items a list takes.
MinItems, MaxItems int
Default any
HasDefault bool
Actions []Action
}
Field is one key of the schema.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is lys-wm's config file, the runtime overrides this program writes over it, and the programs that speak for them.
func (*File) Apply ¶
Apply makes the edits to the override file in one write after lys-wm accepted the result, and has a running lys-wm reload it. A refused or impossible change leaves the file as it was; the config file is only read.
func (*File) Check ¶
Check reports why lys-wm would refuse the override file with the edits made, or nil when it would take it; nothing is written.
type ReadOnlyError ¶
ReadOnlyError is an override file this program cannot write.
func (*ReadOnlyError) Error ¶
func (e *ReadOnlyError) Error() string
func (*ReadOnlyError) Unwrap ¶
func (e *ReadOnlyError) Unwrap() error
type RejectedError ¶
type RejectedError struct{ Reason string }
RejectedError is a change lys-wm refused; the file was not touched.
func (*RejectedError) Error ¶
func (e *RejectedError) Error() string
type ReloadError ¶
type ReloadError struct{ Reason string }
ReloadError is a change that was written but that lys-wm did not take.
func (*ReloadError) Error ¶
func (e *ReloadError) Error() string
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is lys-wm's config schema, parsed at the boundary.
func ParseSchema ¶
ParseSchema reads what lys-wm --config-schema prints.