osd

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 21 Imported by: 1 module, 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 osd is the on-screen display (lys-shell osd/): one layer surface on the configured monitor flashing volume, microphone, brightness, and lock-key events and the toasts `lys-shell toast` pushes, styled by the stylesheet's .osd rules and dismissed after osd.duration.

Index

Constants

View Source
const BrightnessIcon = "ld-sun-symbolic"

BrightnessIcon is the brightness slider's glyph (BRIGHTNESS_ICON).

View Source
const LayoutIcon = "ld-keyboard-symbolic"

LayoutIcon is the keyboard layout notice's glyph.

View Source
const MediaIcon = "ld-music-symbolic"

MediaIcon stands in for a track without art.

Variables

This section is empty.

Functions

func MicrophoneIcon

func MicrophoneIcon(muted bool) string

MicrophoneIcon is the input slider's glyph.

func VolumeIcon

func VolumeIcon(percent float64, muted bool) string

VolumeIcon is the output slider's glyph (methods.rs volume_icon).

Types

type Deps

type Deps struct {
	// Open maps a layer surface.
	Open func(app.LayerConfig) (Window, error)
	// Outputs lists the connected outputs, the primary first.
	Outputs func() []*app.Output
	// Invoke runs fn on the UI loop.
	Invoke func(fn func())
	// After runs fn once d has passed, off the loop.
	After func(d time.Duration, fn func())
	// Sheet styles the surface: the labels and icons take their ink
	// from its cascade. Font is the labels' face.
	Sheet *widget.Stylesheet
	Font  render.Font
}

Deps are the OSD's collaborators.

type Event

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

Event is one OSD flash (messages.rs OsdEvent): a slider (volume, microphone, brightness), a lock-key toggle, or a toast pushed over the widget socket. Build one with Slider, Toggle, or from a toast request.

func NowPlaying added in v0.3.15

func NowPlaying(c mpris.TrackChange) Event

NowPlaying is the active player's new track: its art, title and artist.

func Slider

func Slider(label, icon string, percent float64, muted bool) Event

Slider is a level event: a device's volume or the brightness.

func Toggle

func Toggle(label, icon string, active bool) Event

Toggle is a lock key's new state.

type Layouts added in v0.2.0

type Layouts interface {
	Layout() (string, error)
	Subscribe(ctx context.Context) (<-chan struct{}, func(), error)
}

Layouts is the compositor's keyboard layout: Layout reads the active one, and each tick from Subscribe is the cue to read it again.

type LockKeys added in v0.2.0

type LockKeys func(fn func(keytoggles.Event)) (stop func(), err error)

LockKeys follows the lock keys: it calls fn for each key that turns on or off until stop, which waits for the last call.

type Osd

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

Osd is the display. Its exported methods may be called from any goroutine; its state lives on the UI loop.

func New

func New(d Deps, cfg *config.Config) *Osd

New builds the OSD; nothing maps until the first event after the start-up quiet period.

func (*Osd) DetachOutput

func (o *Osd) DetachOutput(name string)

DetachOutput drops the surface on an unplugged output; the next event maps it on the configured monitor again.

func (*Osd) SetConfig

func (o *Osd) SetConfig(cfg *config.Config)

SetConfig takes a reloaded config; a mapped OSD re-anchors to it (OsdCmd::ConfigChanged).

func (*Osd) Show

func (o *Osd) Show(ev Event)

Show flashes ev (show_event).

func (*Osd) ShowToast

func (o *Osd) ShowToast(req widgetipc.ToastRequest)

ShowToast flashes a `lys-shell toast` request (handle_show_toast).

func (*Osd) Watch

func (o *Osd) Watch(ctx context.Context, audio pulse.Source, light brightness.Source, layouts Layouts, tracks Tracks, locks LockKeys)

Watch follows the audio, brightness, keyboard layout, track change, and lock-key sources until ctx ends (watchers.rs spawn). A nil source is skipped. The levels at start seed the dedupe without flashing, as the Rust watchers' first emission lands inside the quiet period. The lock-key source runs only while the OSD is enabled, since it holds input devices open.

type Tracks added in v0.3.15

type Tracks interface {
	TrackChanges() (<-chan mpris.TrackChange, func())
}

Tracks is the media service's track changes: each one is offered to the OSD, which osd.media filters.

type Window

type Window interface {
	Close()
	SetAnchor(app.Anchor) error
	SetMargin(app.Margins) error
	SetLayer(app.Layer) error
}

Window is the part of a layer window the OSD drives (app.LayerWindow).

Jump to

Keyboard shortcuts

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