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 ¶
- func AnchorsFor(location config.Location) app.Anchor
- func CreateAll(items []config.BarItem, ctx ModuleContext) *widget.Box
- func FindLayout(layouts []config.BarLayout, connector string) (config.BarLayout, bool)
- func Run() error
- func RunWith(cfg *config.Config) error
- type Factory
- type Module
- type ModuleContext
- type TrayService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnchorsFor ¶
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 ¶
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.
Types ¶
type Factory ¶
type Factory func(ctx ModuleContext) (Module, error)
Factory builds one module instance.
type Module ¶
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.
Source Files
¶
- actions.go
- alertdialog.go
- anchors.go
- audiodropdown.go
- bar.go
- battery.go
- batterydropdown.go
- bitwarden.go
- bitwardendropdown.go
- bluetooth.go
- bluetooth_dropdown.go
- bluetooth_helpers.go
- bluetooth_notify.go
- bluetooth_pairing.go
- bluetooth_widgets.go
- brightness.go
- brightnessdropdown.go
- calendardropdown.go
- capture.go
- cava.go
- clock.go
- compositor.go
- compositorws.go
- configwrite.go
- custom.go
- cwsbackends.go
- cwsmodule.go
- cwswidgets.go
- daemons.go
- dashboard.go
- dashboarddropdown.go
- dropdown.go
- dropdown_builders.go
- dropdown_size.go
- dropdown_template.go
- fixed.go
- hyprland.go
- hyprsunset.go
- icon.go
- idleinhibit.go
- keybindmode.go
- keyboardlayout.go
- launcherhost.go
- layout.go
- mail.go
- maildropdown.go
- media.go
- mediadropdown.go
- microphone.go
- modulebutton.go
- modules.go
- netservice.go
- netstat.go
- network.go
- networkdropdown.go
- networkhelpers.go
- networkvpn.go
- notificationdropdown.go
- notifications.go
- notifyservice.go
- portals.go
- power.go
- powerprofiles.go
- recorder.go
- recorderdevices.go
- recorderdropdown.go
- ring.go
- screenshot.go
- secretentry.go
- separator.go
- style.go
- stylesheet.go
- sysinfo.go
- systray.go
- treeman.go
- treemandropdown.go
- usersession.go
- visibility.go
- volume.go
- weather.go
- weatherdropdown.go
- windowtitle.go
- worldclock.go