bar

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 97 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 AnchorsFor

func AnchorsFor(location config.Location) app.Anchor

AnchorsFor maps a bar location onto layer-shell anchors the way the Rust shell's apply_anchors does: the docked edge plus both edges of the stretch axis, so the surface spans the screen while the cross-axis auto-sizes to the content.

func CreateAll

func CreateAll(items []config.BarItem, ctx ModuleContext) *widget.Box

CreateAll builds every item of one layout section into a row: one box.bar-item per layout item (bar/factory.rs BarItemFactory), a group's carrying the bar-group class and the group name as its id, each module inside classed `module` plus its per-instance class. The gaps between items and grouped modules are the stylesheet's margins (bar/layout.css), not box spacing.

A module that cannot be built (its service is unavailable on this system, its compositor is not running) is logged and left out, like module_registry.rs require_service: one missing daemon never takes the bar down.

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() error

Run 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.

func RunWith

func RunWith(cfg *config.Config) 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
	Bluetooth     bluetooth.Source
	Network       network.Source
	Networking    *network.Service // secret agent, VPNs, wifi; nil without NM
	PowerProfiles powerprofiles.Source
	IdleInhibit   *idleinhibit.State
	Treeman       treeman.Source
	Notifications *notifications.Service
	Recorder      *recorder.State
	Mail          *mail.Service
	Bitwarden     *bitwardenHost
	SNI           *sni.Store
	Weather       *weather.Service
	// 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
	// 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)
	// 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.

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
	RefreshMenu(ctx context.Context, it sni.Item) (sni.MenuItem, error)
	MenuClicked(ctx context.Context, it sni.Item, id int32) error
	WatchMenu(key string) (<-chan struct{}, 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.

Jump to

Keyboard shortcuts

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