RediWM is a Wayland compositor written in Zig (OpenGL ES) that includes everything in one process
Settings (ControlCenter)
Settings is an ordinary window with a compositor-drawn body (Backend.shell).
ControlCenter.zig holds its state and lifecycle; tree.zig, keys.zig,
relayout.zig and paint.zig its methods; panel.zig the shared widget
helpers (and panel.ControlCenter); sections/ one file per page.
The body paints into
scene_treeatrender_scaleand presents withpresentOwned.No wl_surface, so focus is "first in
world.toplevels, activated, no seat focus, desktop unfocused" (hasKeyboardFocus).World.focusSurfacedeactivates a previous.shellwindow and callsDesktop.yieldKeyboard;findFocusedToplevelreturns it.Compositor bindings run before it gets keys. Pointer coordinates come from
localPoint.close()frees the content andToplevel.destroys the window (which may animate from a snapshot): clearbackend.shell.control_centerand the node's scene data first, and never close from inside a widget callback.The Services client (
systemd.zig) is live only while its page is on screen (showfromservices.build,hidefromselectPage/detachSettings) or while an IPC query holds a 15 slease. Live means the signal matches,Subscribeand a load; dark meansUnsubscribe, matches removed and the data dropped. NeverRefUnitorLoadUnit: systemd loads the unit and its whole dependency closure, then asks polkit on every call (about 49 ms of PID 1 plus polkitd each, denied when non-interactive, so nothing is ever pinned), and the load/collect churn is broadcast to every subscriber and fed back into the refresh. An unloaded unit is only its unit-file state; nothing is asked of it. A load is ListUnits (its state fields are the rows), ListUnitFiles, thenGetof Transient, TriggeredBy and Type for each loaded unit, once (cached;refresh/daemon reload re-read). Signals apply the values they carry; anything else only setsdirty, and one reload runs aftersettle_ms. systemd broadcasts thousands of UnitNew/UnitRemoved a second under bulk loads, so no signal may cost a call of its own and none may restart a load. The fake incontrol_center.pyemits no such floods; a pass-through proxy that decodes bus messages shows the real traffic without root (BecomeMonitorandDebug.Statsneed it).Saving a theme slider rebuilds the page on release:
ControlCenter.rebuildTree(relayout.zig) carries named sliders' state across (src/ui/AGENTS.md, "Sliders").A rebuild of Appearance costs milliseconds (preset, wallpaper and icon-theme scans) plus a full repaint: background wakes refresh only pages that show their state (audio: General and Audio), and wallpaper thumbnails go straight into their tile (
stripWake). The nav highlights damage the rows they cross, not the list.Printers owns its worker only while the page is selected.
printers.buildstarts it lazily;selectPageand destruction callhide. Socket requests have an absolute deadline and are interrupted through the worker eventfd before joining. USB uevents coalesce into a rescan; no idle timer queries CUPS. State snapshots cross under a mutex; widget strings must be copied into the section arena before the next snapshot replaces them. An older automatic refresh must not clear a newer user action's busy state. Only own jobs are cancellable, rechecked outside the callback; CUPS remains the authority. Reports omit identities and arbitrary status messages. USB libusb queues do not require a usblp node. Readdocs/plans/printers.mdfor the unqualified hardware and distribution-policy acceptance gates. Discovered backend URIs must match the current administration catalog exactly; arbitrary typed vendor/file backends are not allowed. PPD settings usePrinterAddOptionor direct PPD editing after clearing stale IPP defaults, followed by readback. Direct CUPS authentication uses the shared secret widget over locked storage, clears it on submit/cancel/hide, and never stores passwords in the section arena. Hiding also cancels any native authentication wait.The Appearance flame-effect toggles are independent though
window_minimizeandwindow_resizefollowwindow_movein the file.Config.setEnabledpins a following binding to what it showed before the change andsetting_save.saveEffectwrites it (with itspreset) so a reload reads back what was running; the handler then callswindow_move.configure(a reload's diff cannot, the live config already changed). Off by default: nothing is written until a toggle is touched.Global search uses
search_index.zigdestinations (widget names or@plus visible label text), without building hidden sections. Add an index entry with new settings. Typing navigates to the highest-ranked match; the sidebar contains only matching pages, and selecting one reveals its best match while keeping the query. Clearing search keeps the current page and scroll position. UseshowingPage, rather thanpage, in background callbacks: an empty search covers the selected page. The search field owns its text across rebuilds; navigation is deferred until widget dispatch has finished.sections/users_helper.zigowns the account helper request and authorization lifetime;users.zigowns the account UI.Keys & Certificates (
sections/keys*.zig) owns akeys/client.zigonly while selected. The unprivileged siblingrediwm-keysreads key files; the compositor receives metadata and public keys only. The client's single in-flight request has an absolute deadline and owns a child process group; hide/close/lock cancels it, and idle has no worker or timer. Copy snapshots into the section arena before retaining widget strings. Secret fields use locked storage and requests are encoded with the secure allocator, wiped on submit, cancellation, page changes and lock. Never put a passphrase in tool argv, environment, a section arena or logs. Seedocs/plans/keys-certificates.mdfor the currently supported SSH formats and the later agent/certificate phases.
Network page
- The page is
sections/network*.zig:network.zig(section state, the overview, Ethernet and Wi-Fi cards, airplane mode),network_details.zig(the address rows),network_editor.zig(the connection settings editor),network_vpn.zig,network_proxy.zig,network_fields.zig(text fields that keep their text across a rebuild: capture before the arena resets, never read a captured widget afterwards),network_ui.zig(small builders). - Writes go through
network/manager_profile.zig: read the settings withGetSettings, replace only the keys the editor owns,Updatewith the interactive flag. AnUpdatewithout a secret keeps the stored one (verified), so never add secret handling. The Unlock gate ismanager_access.zig; proxy is per user and ungated. i18n.trtext is not astd.fmtformat: usei18n.fmtwith named placeholders.panel.translatedLabelsruns at call time, never in a file-levelconst.- Tests never touch the host:
tests/nm_fake.pyis a fake NetworkManager and polkit on the session bus; the proxy test setsGSETTINGS_BACKEND=keyfilewith a scratchXDG_CONFIG_HOME; nothing may write/dev/rfkill.
Firewall (on the Network page)
sections/firewall*.zig:firewall.zig(state, overview card, the Manage sub-view, actions),firewall_rules.zig(rules list and Add rule form),firewall_cards.zig(listening programs, networks, advanced, other programs' rules, recent blocks),firewall_client.zig(pkexec runs ofrediwm-firewall-helper; seesrc/firewall/AGENTS.md).- The client lives while the Network page is shown:
firewall.startfromnetwork.build;hideon page change, search, close and the screen lock (lock.zig), which also forgets the unlock. One request at a time; the only timers are its deadline and one wake at a pending revert's deadline. - No pkexec unless polkit's actions name this build's helper
(
firewall_client.policyInstalled): otherwise pkexec's generic action asks for a password even to read. Development and test compositors therefore never reach the session's polkit agent;tests/firewall_settings.pystages a policy in its namespace. - Unlock is the helper's
authorizethrough themanageaction (polkitauth_admin_keep); reads useread(no password for an active session). Where a read is refused (exit 126/127, FreeBSD's polkit today) the card says "Unlock to view" and reads go throughmanageafter unlocking; the page never prompts by itself. Child exit values are raw wait statuses. - Reply strings are freed by the next reply: copy them into the tree's
arena (
a.dupe) before a widget keeps them. - Changes that can cut the user off (blocking outgoing, lockdown, removing a
rule that allows SSH) send
revert_after = 20; the overview then offers Keep change.