bar

package
v0.3.21 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 138 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 bar renders lys-shell's bar: the layer surfaces docked to the screen edges, one per output that the config gives a layout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindLayout

func FindLayout(layouts []config.BarLayout, connector string) (config.BarLayout, bool)

FindLayout resolves the layout for one output's connector name: the exact monitor match wins, then "*" as the fallback, and extends chains inherit the unset sections of their parent layout. A monitor with neither an exact entry nor a "*" entry gets no bar.

func Run

func Run(session *dbus.Conn) error

Run hands the session's cursor to lys-login's display manager in the background, loads the user config and shows the bar. A config failure logs and falls back to defaults — the Rust shell's behavior — rather than refusing to start; a failed cursor record only logs, as the greeter then keeps its own cursor.

func RunWith

func RunWith(cfg *config.Config, session *dbus.Conn) error

RunWith shows the bar from a prepared config: one layer surface per output the layout gives a visible bar, then the lys-ui loop.

Types

type Factory

type Factory func(ctx ModuleContext) (Module, error)

Factory builds one module instance.

type Module

type Module interface {
	Root() widget.Widget
}

Module is one bar module: a live widget tree plus whatever timers keep it current. The interface grows update/message plumbing as services land.

func Create

func Create(name string, ctx ModuleContext) (Module, error)

Create builds the module named by a layout entry. Custom modules (custom-*) resolve through the [modules.custom] definitions; a name outside both is an error, logged by the caller while the rest of the bar builds - as the Rust factory warns "module not implemented" for a schema module without one (updates).

type ModuleContext

type ModuleContext struct {
	Config     *config.Config
	App        *app.Application
	Font       render.Font
	Style      *barStyle
	Hyprland   *hyprland.Connection
	Battery    upower.Source
	Brightness brightness.Source
	Pulse      pulse.Source
	Media      mpris.Source
	// Calendar holds the vdir calendars the calendar dropdown and the
	// clock read; nil in headless construction.
	Calendar *calendar.Store
	// Lyrics looks up the media dropdown's lyrics; nil when the cache
	// directory is unknown.
	Lyrics        *lyrics.Service
	Bluetooth     bluetooth.Source
	Network       network.Source
	Networking    *network.Service // secret agent, VPNs, wifi; nil without NM
	PowerProfiles powerprofiles.Source
	IdleInhibit   *idleinhibit.State
	// ScreenShares follows the portal's screen shares on the shell's
	// session bus; nil without one.
	ScreenShares shareSource
	// Cameras follows the processes holding a camera open; nil when the
	// video devices cannot be watched.
	Cameras cameraSource
	// Idle is the built-in idle policy, nil when it does not run.
	Idle          *idle.Service
	Treeman       treeman.Source
	Notifications *notifications.Service
	Recorder      *recorder.State
	Mail          *mail.Service
	// BackgroundApps is the portal's background apps, nil without a
	// session bus.
	BackgroundApps backgroundAppSource
	Bitwarden      *bitwardenHost
	SNI            *sni.Store
	Weather        *weather.Service
	// Tasks is the window list the minimized-windows modules and the docks
	// share; nil when the compositor offers no foreign-toplevel list.
	Tasks *taskHub
	// System is the shell's one system bus connection, nil without one;
	// what reads it never closes it.
	System *dbus.Conn
	// SetConfig writes a runtime override and persists it (the Rust
	// ConfigService property set the dropdowns use); nil without a
	// config service.
	SetConfig func(path string, value any)
	// Toast shows an OSD toast (the Rust ToastBus); nil without an OSD.
	Toast func(label, icon string)
	// Clipboard is the session clipboard history, nil when the
	// compositor has no data-control protocol (the launcher's
	// clipboard mode reads it).
	Clipboard *clipboard.Clipboard
	// Tray drives the tray items and their menus; nil without a host.
	Tray          TrayService
	CustomUpdates *customUpdates
	// PowerMenu is the native power menu the power module's :menu
	// opens; nil without one.
	PowerMenu *powermenu.Menu
	// Dropdowns opens the dropdown:<name> popovers; RunWith owns one
	// registry across outputs.
	Dropdowns *dropdownRegistry
	// Attachers collects modules that need the live layer surface
	// (idle-inhibit binds its inhibitor to it); RunWith calls Attach
	// on each once the layer exists.
	Attachers *[]interface{ Attach(app.Host) }

	// Connector is the output this bar instance sits on; per-output
	// modules (workspaces) key their state on it.
	Connector string
	// Polls shares each config key's sampling across the bars and holds it
	// back while the session is idle or locked; nil samples alone, unpaused.
	Polls *pollHub
	// Screenshot starts a capture on the in-process screenshot host
	// (the `lys-shell screenshot ...` builtin); nil before the host is up.
	Screenshot func(mode, target string)
	// ReadScreen reads a dragged region's text or QR code (the `lys-shell
	// screenshot text|qr` builtin); nil before the host is up.
	ReadScreen func(kind screenshot.ReadKind)
	// PickColor picks a pixel of the screen and copies its color; nil
	// before the host is up.
	PickColor func()
	// Theme is the bar stylesheet every bar root attaches; nil in
	// headless construction, where the tree builds unstyled.
	Theme *apptheme.Theme
	// Alert replaces showAlert's modal dialog (tests answer it); nil
	// asks through the application.
	Alert func(spec alertSpec, answer func(accepted bool))
	// contains filtered or unexported fields
}

ModuleContext carries what a module needs at construction time: the resolved bar style, the config, and the loop it schedules timers on. App is nil only in headless construction (tests): the module then builds its tree without scheduling updates. Hyprland is nil when the compositor is not Hyprland; Hyprland-only modules error in that case.

func (ModuleContext) Every

func (c ModuleContext) Every(d time.Duration, fn func())

Every schedules fn on the application loop; a no-op when the context is headless.

func (ModuleContext) Invoke

func (c ModuleContext) Invoke(fn func())

Invoke marshals fn onto the loop goroutine, or for a headless context runs it inline under headlessLoop. A retired generation's work is dropped either way.

func (ModuleContext) Life

func (c ModuleContext) Life() context.Context

Life is the module's lifetime: canceled when its generation retires (a config reload), never for a context outside one. Module loops and subscriptions run under it.

func (ModuleContext) OnRetire added in v0.3.3

func (c ModuleContext) OnRetire(release func())

OnRetire runs release as the module's generation retires, before retire returns and so before the next generation mounts: for what only one holder can have, which the next generation's module would be refused. Call it on the loop, as mounting does. Outside a generation nothing retires.

type TrayService

type TrayService interface {
	Activate(ctx context.Context, it sni.Item) error
	SecondaryActivate(ctx context.Context, it sni.Item) error
	ContextMenu(ctx context.Context, it sni.Item) error
	// OpenMenu is AboutToShow and the layout, once per showing.
	OpenMenu(ctx context.Context, it sni.Item) (sni.MenuItem, error)
	// MenuLayout re-reads an open menu's layout without AboutToShow.
	MenuLayout(ctx context.Context, it sni.Item) (sni.MenuItem, error)
	// SubmenuOpening is AboutToShow for a submenu as it opens; true asks
	// for the layout to be read again.
	SubmenuOpening(ctx context.Context, it sni.Item, id int32) (bool, error)
	MenuClicked(ctx context.Context, it sni.Item, id int32) error
	// WatchMenu ticks on the item's menu changes until stop, which
	// closes the feed and may be called more than once.
	WatchMenu(key string) (<-chan struct{}, func())
	// WantPixmapSize keeps the items' pixmaps for px device pixels
	// until release.
	WantPixmapSize(px int) (release func())
}

TrayService is what the tray module drives: the item controls, the DBusMenu calls, and the open-menu change feed. The shell wires the SNI host; tests fake it.

func NewTrayService

func NewTrayService(h *sni.Host) TrayService

NewTrayService adapts a running SNI host.

Source Files

Jump to

Keyboard shortcuts

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