Documentation
¶
Overview ¶
Package sni is the StatusNotifierItem tray service: the watcher and host D-Bus roles, item discovery, and the snapshot store the bar module renders.
Index ¶
- Constants
- func ParseAddress(reg string) (bus, path string)
- func ServeDaemon(conn *dbus.Conn, store *Store, activator Activator, isWatcher bool) (func(), error)
- type Actions
- func (a *Actions) AboutToShow(ctx context.Context, it Item, id int32) (needUpdate bool, err error)
- func (a *Actions) Activate(ctx context.Context, it Item, x, y int32) error
- func (a *Actions) ContextMenu(ctx context.Context, it Item, x, y int32) error
- func (a *Actions) MenuClicked(ctx context.Context, it Item, id int32) error
- func (a *Actions) MenuLayout(ctx context.Context, it Item) (MenuItem, error)
- func (a *Actions) OpenMenu(ctx context.Context, it Item) (MenuItem, error)
- func (a *Actions) Scroll(ctx context.Context, it Item, delta int32, orientation string) error
- func (a *Actions) SecondaryActivate(ctx context.Context, it Item, x, y int32) error
- type Activator
- type Category
- type Daemon
- type Host
- type Item
- type ListRow
- type MenuItem
- type Pixmap
- type Status
- type Store
- type ToggleState
- type ToggleType
- type Tooltip
Constants ¶
const ( DaemonName = "dev.stubbe.lys.SystemTray1" DaemonPath = dbus.ObjectPath("/dev/stubbe/lys/SystemTray") )
lys-shell's own interface over the tray, which `lys-shell systray` drives (wayle-systray/src/dbus).
const ( WatcherName = "org.kde.StatusNotifierWatcher" WatcherPath = "/StatusNotifierWatcher" WatcherIface = "org.kde.StatusNotifierWatcher" HostIface = "org.kde.StatusNotifierHost" ItemIface = "org.kde.StatusNotifierItem" PropsIface = "org.freedesktop.DBus.Properties" // ProtocolVersion is the watcher's advertised protocol version. ProtocolVersion = int32(0) )
D-Bus names for the SNI protocol.
const MenuIface = "com.canonical.dbusmenu"
MenuIface is the DBusMenu interface tray items publish their menus on.
Variables ¶
This section is empty.
Functions ¶
func ParseAddress ¶
ParseAddress splits a watcher registration ("bus/path") into its bus name and object path. A missing path defaults to /StatusNotifierItem, as most items register bare.
Types ¶
type Actions ¶
type Actions struct {
// contains filtered or unexported fields
}
Actions drives one item (the bar's click handlers).
func (*Actions) AboutToShow ¶ added in v0.2.0
AboutToShow tells the app the (sub)menu id is about to show, the spec's once per showing; needUpdate is the app asking for its layout to be read again before it shows.
func (*Actions) ContextMenu ¶
ContextMenu asks the item to show its own menu.
func (*Actions) MenuClicked ¶
MenuClicked sends the clicked event for a row (menu_event with MenuEvent::Clicked, data 0, the Unix time).
func (*Actions) MenuLayout ¶ added in v0.2.0
MenuLayout reads the full layout (GetLayout) without AboutToShow: the re-read after a LayoutUpdated or ItemsPropertiesUpdated, which an app may itself send in answer to AboutToShow.
func (*Actions) OpenMenu ¶ added in v0.2.0
OpenMenu is the menu about to be shown: AboutToShow on the root (a failure is fine - not every app implements it), then the full layout. The spec calls AboutToShow once per showing, so a menu already open re-reads with MenuLayout instead.
type Category ¶
type Category string
Category describes the kind of application behind an item.
const ( CategoryApplicationStatus Category = "ApplicationStatus" CategoryCommunications Category = "Communications" CategorySystemServices Category = "SystemServices" CategoryHardware Category = "Hardware" )
Categories.
func ParseCategory ¶
ParseCategory defaults unknown strings, per the SNI spec.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the dev.stubbe.lys.SystemTray1 object (SystemTrayDaemon).
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host plays the host role against a watcher (ours or an existing one), tracks items and their property changes, and hands out the item controls.
func NewHost ¶
NewHost connects to the session bus and claims the roles: when no watcher is running, this process becomes the watcher and hosts against itself.
func (*Host) IsWatcher ¶
IsWatcher reports whether this process serves the watcher role (the Rust service in TrayMode::Auto having claimed it).
func (*Host) WantPixmapSize ¶ added in v0.2.0
WantPixmapSize asks the host to keep, of every pixmap property, the pixmap BestPixmap picks for px device pixels, until release. Items are read again whenever the set of wanted sizes changes, so a new size is served at once and a dropped one frees its pixmaps. It panics on a non-positive size, a programming error.
type Item ¶
type Item struct {
// Bus is the item's unique or well-known bus name; Path the
// StatusNotifierItem object path.
Bus string
Path string
ID string
Title string
Category Category
Status Status
ItemIsMenu bool
// IconPixmap, AttentionIconPixmap and OverlayIconPixmap hold only
// the pixmaps BestPixmap picks for the sizes the host's consumers
// want (Host.WantPixmapSize). AttentionMovieName is not read: the
// tray draws the still attention icon instead.
IconName string
IconPixmap []Pixmap
OverlayIconName string
OverlayIconPixmap []Pixmap
AttentionName string
AttentionIconPixmap []Pixmap
IconThemePath string
Tooltip Tooltip
MenuPath string
}
Item is one tray item's snapshot (the SNI properties the bar needs).
type MenuItem ¶
type MenuItem struct {
ID int32
Label string
Enabled bool
Visible bool
Separator bool
Toggle ToggleType
ToggleState ToggleState
IconName string
// IconData is PNG data (the icon-data property).
IconData []byte
// Shortcut is the spec's shortcut list: each entry is modifiers
// then the key ("Control", "Shift", "q").
Shortcut [][]string
Children []MenuItem
}
MenuItem is one DBusMenu node with its children (types/menu.rs MenuItem). The root is the invisible container whose children are the menu's rows.
type Pixmap ¶
Pixmap is ARGB32 icon data in network byte order: Data holds at least Width x Height pixels.
func BestPixmap ¶ added in v0.2.0
BestPixmap is the pixmap drawn in a box of target device pixels: the one closest to target x target by summed width and height distance, the first on ties. It is the one rule both the host's retention and the tray's drawing follow.
type Status ¶
type Status string
Status describes how prominent an item should be.
const ( StatusPassive Status = "Passive" StatusActive Status = "Active" StatusNeedsAttention Status = "NeedsAttention" )
Statuses.
func ParseStatus ¶
ParseStatus defaults unknown strings, per the SNI spec.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the item set with change feeds.
func (*Store) Put ¶
Put inserts or replaces an item, preserving registration order. An item that reads as it did changes nothing, so no feed ticks.
type ToggleState ¶
type ToggleState int8
ToggleState is a toggle row's state; ToggleUnknown is the spec's -1.
const ( ToggleUnchecked ToggleState = 0 ToggleChecked ToggleState = 1 ToggleUnknown ToggleState = -1 )
Toggle states.
type ToggleType ¶
type ToggleType uint8
ToggleType is a menu row's toggle kind (types/menu.rs ToggleType).
const ( ToggleNone ToggleType = iota ToggleCheckmark ToggleRadio )
Toggle types.