System tray
Purpose
Supports applications that run in the background with only an icon in the bar through the StatusNotifierItem protocol, with the core as watcher and host and the bar and menus drawn as web UI.
Requirements
Requirement: Core owns the watcher without replacing another
The core SHALL ask for org.kde.StatusNotifierWatcher with DO_NOT_QUEUE and without REPLACE_EXISTING; when another watcher owns the name, the core SHALL only be a host of that watcher and MUST NOT replace it. Full text: section Decisions.
Scenario: KDE or GNOME watcher exists
- WHEN a KDE or GNOME session already owns the watcher name
- THEN the core is only a host of that watcher (state host)
Requirement: Bus errors do not close the connection
A refused call, a timeout or a dropped reply while the core takes the name or asks the watcher MUST NOT close the bus connection; the core SHALL show unavailable with a fixed reason and ask again after 1, 3, then every 10 s. Full text: section Decisions.
Scenario: Busy watcher
- WHEN a call is refused or times out
- THEN the state is unavailable with the fixed reason and the core asks again after 1, 3, then every 10 s
Requirement: No XEmbed
The legacy XEmbed tray MUST NOT be implemented, because an embedded X11 window in the bar would break the rule that every visual component is web UI. Full text: section Decisions.
Scenario: X11 tray client
- WHEN an application only speaks XEmbed
- THEN it is not supported
Requirement: Item status display
Passive items SHALL be hidden, active items SHALL show their icon, and NeedsAttention items SHALL show the attention icon when the item has one plus a pulsing dot; the overlay icon and AttentionMovieName are not drawn. Full text: section Decisions.
Scenario: Passive item
- WHEN an item is Passive
- THEN it is hidden
Requirement: The agent has no tray access
No model tool SHALL list tray items, read a menu or call a tray action; system_context.tray SHALL have only state, reason, owner and count, with a fixed reason text; the tray routes SHALL require the token of the protected host, which generated HTML and isolated panels never get. Full text: section Decisions.
Scenario: Agent reads the tray
- WHEN the agent reads system_context.tray
- THEN it gets only state, reason, owner and count
Requirement: Tray menu is a protected panel
A right click SHALL open the protected panel tray-menu only on an item with a loadable dbusmenu; otherwise the item gets ContextMenu(x, y) and the application draws its own menu. A plugin MUST NOT take the tray-overflow id, whose page can open only tray-menu. Full text: sections Decisions and Host side.
Scenario: Right click
- WHEN the user right clicks an item
- THEN the tray-menu panel opens
Requirement: Registration limits
The watcher SHALL enforce at most 64 items and 8 per registering connection (org.freedesktop.DBus.Error.LimitsExceeded) and at most 16 hosts, and the name of a registered item MUST have an owner. Full text: section Bus contract.
Scenario: Ninth item from one connection
- WHEN a connection registers a ninth item
- THEN the call fails with LimitsExceeded
Requirement: Removal when the owner leaves
NameOwnerChanged to no owner SHALL remove the items of that unique or well-known name, and a closed menu goes with its item. Full text: section Bus contract.
Scenario: Application exits
- WHEN an application leaves the bus
- THEN its items are removed
Requirement: Text and icon limits
Markup and control characters SHALL be removed, with limits of 500 menu entries, menu depth 8, titles and labels 128 characters and tooltip body 512 characters; icon data is 8 MiB for the bar view, 64 KiB per menu icon and 2 MiB per menu. Full text: section Bus contract.
Scenario: Oversized icon
- WHEN icon data exceeds the bar limit
- THEN later items show a letter
Requirement: Icon file safety
Only regular .png and .svg files of at most 512 KiB (64 KiB in a menu) SHALL be read, the open MUST NOT wait on a FIFO, and an SVG SHALL show in an img, which runs no script. Full text: section Icons.
Scenario: FIFO or device link
- WHEN an icon path links to a FIFO or device
- THEN it is never read
Requirement: Tray routes are strictly typed
The tray routes SHALL require the host token and each SHALL take exactly its documented keys with integer values in range; an unknown item, bad input, a stale menu for a click or an expand, or a timed-out call SHALL answer HTTP 400. Full text: section Host side.
Scenario: Stale menu click
- WHEN a click arrives on a stale drawing (serial changed)
- THEN it is refused with HTTP 400
Requirement: Service start conditions
The core SHALL start the tray only when AGENT_NATIVE_COMPOSITOR=smithay or AGENT_NATIVE_TRAY=1, SHALL stay off with AGENT_NATIVE_TRAY=0, and SHALL take the bus address only from DBUS_SESSION_BUS_ADDRESS. Full text: section When the service starts.
Scenario: Tray disabled
- WHEN AGENT_NATIVE_TRAY=0
- THEN the tray does not start
Requirement: Panel declaration is added once
A core of the real desktop SHALL append tray-menu once to an existing valid web-panels.json with the marker .web-panels-protected-v2, keep every existing entry, and a later removal by the user MUST stay. Full text: section Panel declaration.
Scenario: User removed tray-menu
- WHEN the marker exists and the user removed the panel
- THEN it is not added again
Requirement: Tray capacity route
trayVisibleCount SHALL store a capacity from 0 to 64, POST /api/tray/visible-count SHALL accept exactly {count} and persist it, and no agent tool, generated content or plugin SHALL receive the route. Full text: section Visible capacity of the Office tray.
Scenario: Capacity set
- WHEN the user drags the separator
- THEN the capacity is persisted and the overflow shows only items after it
Status
Doc status: current contract. Implemented in core/tray*.js; active in the live session only after a coordinated login. Checked 2026-11-10.
Introduction
Applications that run in the background with only an icon in the bar (chat
clients, Steam, Nextcloud, the network applet) use the StatusNotifierItem (SNI)
protocol on the session bus. The core is the org.kde.StatusNotifierWatcher
and the host of the session. The protected top bar draws the icons as web UI,
and a protected panel draws their com.canonical.dbusmenu menus. Smithay only
places the windows. Status: implemented in the sources, proved with a private
bus, a synthetic core and a nested QA run. It is not active in the shared
session until the next coordinated login.
Why the icons did not work
The user reported it on 2026-11-01: "falta suportar aplicativos que ficam em
segundo plano abertos somente com icones na barra, não está funcionando". A
read-only busctl --user list of the live session showed no owner of
org.kde.StatusNotifierWatcher. Without a watcher an application cannot
register its icon: Qt hides it, Electron and libappindicator wait for the
watcher. The core had no watcher, no host and no tray UI.
Decisions
- The core owns the watcher and is the host.
core/tray.jsasks for the bus name withDO_NOT_QUEUEand withoutREPLACE_EXISTING. It also asks fororg.kde.StatusNotifierHost-<pid>-1, and the watcher answersIsStatusNotifierHostRegisteredwith true. When the core takes the name it emitsStatusNotifierHostRegistered, so items that started earlier register again (they also follow the owner change of the watcher name). - Another watcher is not replaced. When a KDE or GNOME session already owns
the name, the core is only a host of that watcher (state
host): it callsRegisterStatusNotifierHoston the unique owner of the watcher name (so only that watcher can answer) with its well-known host name (KDE wants it; the GNOME AppIndicator watcher refuses every host, and the core goes on), readsRegisteredStatusNotifierItems(KDEservice/pathor GNOMEservice@/path) and follows the registered and unregistered signals. When the name passes to a queued watcher, the core follows that one; when the last watcher leaves, the core takes the name. A refused call, a timeout or a dropped reply while the core takes the name or asks the watcher for its owner and items (a busy watcher, or a busy bus daemon) does not close the bus connection: the core showsunavailablewith the fixed reason "Session bus error: a call was refused or timed out" and asks again after 1, 3, then every 10 s. A success, or a new connection, starts the delays again at 1 s. - No XEmbed. The legacy XEmbed tray needs an X11 tray manager window and Xwayland embedding. The compositor has no X11 tray, current applications (Qt 5 and 6, GTK 3 with libappindicator, Electron, Chromium) speak SNI, and an embedded X11 window in the bar would break the rule that every visual component is web UI. XEmbed is not implemented.
- Passive items are hidden, as the specification allows. Active items
show their icon. NeedsAttention items show
AttentionIconNameorAttentionIconPixmapwhen the item has one, and a dot that pulses (still underprefers-reduced-motion). The overlay icon andAttentionMovieNameare not drawn. - Behind an arrow under the theme Office. The taskbar shows no tray icon: an arrow, only with an item, opens the protected panel
tray-overflow, which reads the same/api/trayroutes as a bar and opens the sametray-menuon a right click (openspec/specs/ui-themes/spec.md). A plugin cannot take that id, and its page can open onlytray-menu. - The menu is a protected panel. A right click opens
tray-menu, a protected panel under the right end of the top bar (anchor top-right, offsets 8/40, 300x560,fit_content,close_on_blur, keyboard). It is not placed under the icon: panel places come fromweb-panels.json, and a place per click needs a compositor change. The panel shows submenus inline (an arrow opens them) and draws check marks and radio marks. Since 2026-11-02 the panel is React and HeroUI (openspec/changes/archive/2026-11-02-heroui-migration/design.md, phase 4): one HeroUI Menu (role=menu), each open submenu a labelledrole=groupsection below its entry, Gravity UI icons for the marks and arrows; application icons stay as the application sends them. - The agent has no tray access. No model tool lists tray items, reads a
menu or calls a tray action.
system_context.trayhas only the status (state,reason,owner,count); the reason is fixed text, never the error text of another bus client. The tray routes need the token of the protected host. Generated HTML and isolated panels never get that token. The genericexecute_commandtool runs as the user and can talk to the session bus like any process of the user; this change does not remove that authority.
Bus contract
| Item | Behavior |
|---|---|
| Watcher object | /StatusNotifierWatcher, interface org.kde.StatusNotifierWatcher, plus Properties (Get, GetAll; Set is refused), Introspectable and Peer |
RegisterStatusNotifierItem(s) |
An object path uses the sender as the service (libappindicator). A bus name uses /StatusNotifierItem. The key is service + path, as KDE lists it. The name must have an owner. The call returns before the core reads the item, so a client that waits for the reply never blocks the read |
RegisterStatusNotifierHost(s) |
Recorded, at most 16 hosts; emits StatusNotifierHostRegistered |
| Properties | RegisteredStatusNotifierItems (items that answered their first read), IsStatusNotifierHostRegistered true, ProtocolVersion 0 |
| Signals | StatusNotifierItemRegistered(s) after the first good read, StatusNotifierItemUnregistered(s), StatusNotifierHostRegistered, StatusNotifierHostUnregistered |
| Item interface | org.kde.StatusNotifierItem, then org.freedesktop.StatusNotifierItem for the first read |
| Item read | GetAll after the registration and 100 ms after any item signal (NewIcon, NewStatus, NewToolTip and the others). One read runs per item; a signal during a read asks for one more; two reads of one item start at least 1 s apart, and all items together start at most 16 reads per second (the others wait in a queue). An item whose first read fails stays pending (hidden, not listed): it is read again after 1, 3 and 10 s, on any of its signals and when it registers again, and leaves with its owner. After the last retry it stays only when its own owner registered it (or a foreign watcher listed it) and that owner still exists; a registration by the owner after another connection planted the item makes the owner its registrar. The name must have an owner at registration, a unique name too, and the bus daemon and the core cannot own an item. At most 16 items whose first read failed stay pending; past that the newest one leaves. A read that still runs does not count, and pending items never block a registration (they still count toward the limits of 64 items and 8 per registrar) |
| Removal | NameOwnerChanged to no owner removes the items of that unique name or well-known name. A closed menu goes with its item |
| Limits | 64 items, 8 per registering connection (org.freedesktop.DBus.Error.LimitsExceeded), 3 s per call, 500 menu entries, menu depth 8, titles and labels 128 characters, tooltip body 512 characters. Icon data: 8 MiB for the bar view (later items show a letter), 64 KiB per menu icon and 2 MiB per menu. Markup and control characters are removed |
| Match rules | Built only from names and paths that passed the D-Bus name and path checks, so a client cannot inject a rule |
Icons
core/tray-icons.js turns every icon into a data URL, so the bar needs no
file route:
IconNameis looked up first inIconThemePathof the item, then in the icon theme of the desktop (gsettingsicon-theme, read again every minute) and itsInheritschain (eight themes at most), thenhicolorand thepixmapsfolders. The index of each theme comes fromDirectoriesof itsindex.themeand is kept for ten minutes. Scalable icons win, then the smallest size not below 24, then the largest.- An absolute
IconNameis read as a file. - Without a match,
IconPixmap(ARGB32 in network byte order) becomes a PNG: the smallest pixmap at least 32 pixels wide, else the largest, at most 256x256. The compression runs in the thread pool, not on the event loop.
Only regular .png and .svg files of at most 512 KiB are read (64 KiB in a
menu). The type and size come from the open file, and the open never waits on
a FIFO, so a link to a device or a FIFO is never read; index.theme follows
the same rule. A PNG must have the PNG signature and an SVG must start with
markup. Each theme folder is read once, entry by entry, up to 40000 files in
600 folders per system theme and 2000 files in 64 folders per item theme path;
an item theme path is read for the desktop theme and hicolor only, and an item
theme path that is a system root is read once, as that root. One lookup reads
at most 4 files that are not a valid image (2 MiB); missing files do not
count. The core
keeps the indexes of the 128 system themes and of the 16 item theme paths used
last, in two caches, so the item paths never push the system themes out; items
that show at once share one build of an index. An SVG shows in an <img>,
which runs no script. Icons whose name ends with -symbolic are drawn light on
the dark top bar. Menu entries use icon-data (PNG) or icon-name.
Host side
- The panel launchers (
#web-panel-buttons) are icon-only links (Commandfordesktop-actions,Activityforsystem-metrics,PanelTopfor any other id), with the panel title asaria-labeland tooltip and no visible word. - The top bar has
#tray-itemsbefore the panel launchers, in#desktop-indicators(so the bottom bar of an older compositor shows it too).host/tray.jswrites the items tohost/bar-state.js, and the React top bar (ui-src/host/bars.jsx, HeroUI phase 9) renders one HeroUI Button per item, with the tooltip title and body as its title and the title as its accessible name. The title and the icon are text and an image URL only. - A click calls
Activate(x, y). An item withItemIsMenu, or one that refusesActivate, gets the right click behavior instead. - A middle click calls
SecondaryActivate(x, y). - A right click asks the core to load the menu (
AboutToShow(0),GetLayout(0, -1, []), eventopened) and opens thetray-menupanel. An item without a dbusmenu (noMenu,/or the Qt/NO_DBUSMENU), or whose menu fails to load, getsContextMenu(x, y), and the application draws its own menu. A newer right click replaces a menu that still loads, and the older item gets nothing. - The wheel calls
Scroll(±120, "vertical" | "horizontal")once per 60 ms, in the Qt convention (positive is up). - Keyboard of the menu panel: Up and Down move between the enabled entries that show (with wrap), Home and End, and typeahead by label (React Aria); Enter or Space runs an entry; Right opens a submenu; Left closes the submenu around the focus and focuses its entry; Escape closes the panel. A pointer over an entry focuses it.
- The menu panel sends
Event(id, "clicked")for an enabled leaf entry of the current drawing,AboutToShow(id)andopenedfor a submenu, andclosedwhen the panel hides. A click on a stale drawing (the serial changed) is refused. The core reads the menu again onLayoutUpdatedandItemsPropertiesUpdated, at most once per second, and wakes the panel only when the entries changed. A click closes only its own menu. While a new menu loads, the panel says so instead of drawing an empty menu. - The coordinates are the screen position that Chromium reports for the click.
No host window holds a new event stream (all host windows share one
connection pool, see test/held-streams.test.js). The bar view of the top bar
carries revisions.tray, and the bar reads GET /api/tray when it changes.
Both use the same composite revision, <item-revision>:<visible-count>, so a
change in the protected visible icon count invalidates the bar even without a
StatusNotifier event. The menu retains its independent numeric revision.
The bottom bar of an older compositor asks every 2 s with ?after=<revision>,
and an unchanged tray answers without the items. The menu panel asks every
500 ms while it shows.
Routes (host token required): GET /api/tray[?after=N],
GET /api/tray/menu[?after=N], and POST /api/tray/{activate,secondary,menu}
with {id, x, y}, POST /api/tray/scroll with {id, delta, orientation},
POST /api/tray/menu/{click,expand} with {serial, entry} and
POST /api/tray/menu/close with {serial}. Each takes exactly these keys,
with integer values in range and orientation "vertical" or "horizontal". An action answers {ok: true}, or {ok: false}
when the application refused the call or a newer right click replaced the
request (the bar logs it). An unknown item, bad input, a stale menu for a click
or an expand, and a D-Bus call that timed out answer HTTP 400. A close with a
stale serial answers {ok: true} and leaves the newer menu open. A click
waits for the reply of the clicked event (at most 3 s) and ignores its
result; opened and closed are sent without waiting.
The host opens the menu with window.open("/web-panel/tray-menu?show"). The
window open handler of the bars treats ?show as "show and keep shown"; a
launcher without a query still toggles its panel.
When the service starts
The same rule as the notifications: the core starts the tray when
AGENT_NATIVE_COMPOSITOR=smithay or AGENT_NATIVE_TRAY=1, and
AGENT_NATIVE_TRAY=0 turns it off. The address comes only from
DBUS_SESSION_BUS_ADDRESS. A synthetic core of the tests never inherits the
session bus of the user.
Panel declaration
New installs get tray-menu from scripts/link-interface.py and
PanelRegistry.defaults(). A core of the real desktop appends it once to an
existing valid web-panels.json, with the marker .web-panels-protected-v2
(the v1 marker covers the notification panels and the volume indicator). It
keeps every existing entry, and a later removal by the user stays. The
compositor needs no change: a protected panel with an unknown id keeps its
declared anchor and offsets. In the window layers model it
is a protected panel in the overlay band, like the other protected panels.
Verification
test/tray.test.jsruns on a privatedbus-daemon: the watcher properties and signals, registration by name and by object path, a property signal that reads the item again, Passive and NeedsAttention, removal when the client leaves, the limits, refused arguments, an item that never answers, the clicks, the scroll, the dbusmenu (labels, separators, check marks, radio, submenus, hidden and disabled entries, stale serials,opened,clickedandclosed), theActivatefallback,ContextMenu, the host mode beside a foreign watcher and the take-over when it leaves, the icon lookup and the route checks.test/tray-http.test.jsstarts a synthetic core with a private bus: the routes refuse a request without the token, show a registered item, answerunchanged, forward a click, and serve the protected menu panel.- Nested QA:
scripts/nested-qa.py start --session-busgives the run a private session bus (no service directory, so no bus activation), andnested-qa.py launch -- COMMANDstarts a client inside the run. The fixturetest/fixtures/tray-client.cjsis the realTrayof Electron. Run c7e350ec (2026-11-01) used it and VLC (Qt 5,--qt-system-tray) as two real clients: both icons showed in the top bar; a click, a middle click and the wheel reachedActivate,SecondaryActivateandScroll(dbus-monitoron the private bus); the Electron icon changed after its click; a right click opened both menus (Qt with entry icons), a submenu opened inline, a menu entry reached the application and closed the panel, a check mark followed the state, Escape closed the panel, and a stopped client lost its icon. See docs/work-log-2026-11.md.
Not covered: the live session (it needs the next login), a second monitor,
libappindicator (GTK) clients, NeedsAttention from a real client, the
tooltip popup (the button has the text as its title and accessible name), and
the placement of the menu under its icon.
Visible capacity of the Office tray
Drag the separator at the left of the Office tray to choose its capacity in whole icon slots: left reveals more icons; right moves them into the existing overflow panel. Left/Right arrows increase/decrease capacity, Home hides all, and End shows the current set. The React handle exposes its value as an accessible separator and names these actions in its title. Since 2026-11-09 the arrow comes right after the handle, before the visible icons, as in the Windows 10-style reference of openspec/specs/ui-themes/spec.md.
trayVisibleCount in profile state stores a capacity from 0 to 64, with 0 as
the compatibility default. Fewer icons occupy only their natural width, without
reserving unused slots. The protected POST /api/tray/visible-count accepts
exactly {count} and persists it. The tray poll includes capacity in its
revision, so bar and overflow update even without a new application event.
Overflow shows only items after that capacity. No agent tool, generated content
or plugin receives the route. Glass keeps its existing tray. This host/core
change needs activation once; profile CSS edits keep their live update flow.