ui/dbus_portal
lib/ui/dbus_portal.vklib/ui/dbus_portal.vk
Pure-Veko Linux Desktop Shell integration (Slice 4):
D-Bus v1 binary wire codec, XDG Desktop Portals (FileChooser, Notification, GlobalShortcuts),
StatusNotifierItem (SNI) system tray, and AF_UNIX session bus transport.
- Zero top-level mut globals: all state lives in LinuxShellState.
- Calls ffi/* builtins directly inside local helpers (no use [ffi]) so consumers work under .ui.
- Zero net/* imports: AF_UNIX session transport uses libc.so.6 when live.
- Deterministic headless simulator mode when sh.headless is true, VEKO_HEADLESS=1, or non-Linux.
LinuxShellState = struct { headless bool = ..., serial i64 = ..., tray_active bool = ..., tray_tooltip str = ..., tray_items block = ..., tray_click_action any = ..., shortcuts map = ..., id_to_chord map = ..., next_hk_id i64 = ..., sim_notifications block = ..., dbus_log block = ... }
dbus-pad-len = fn [n i64, align i64] i64
Rounds n up to the next multiple of align (power-of-two boundary).
dbus-pack-string = fn [mut buf bytes, s str]
Packs a D-Bus STRING ('s') or OBJECT_PATH ('o'): 4-byte align, u32 LE length, UTF-8 bytes, NUL.
dbus-pack-signature = fn [mut buf bytes, sig str]
Packs a D-Bus SIGNATURE ('g'): 1-byte length, UTF-8 bytes, NUL.
dbus-build-method-call = fn [serial i64, dest str, path str, iface str, member str, body_sig str, body bytes] bytes
Builds a complete D-Bus v1 little-endian ('l', proto 1) METHOD_CALL packet.
dbus-parse-header = fn [raw bytes] any
Validates and parses a D-Bus v1 message header (LE 'l' or BE 'B').
dbus-session-socket-path = fn [] str
Resolves the D-Bus session bus AF_UNIX socket path from DBUS_SESSION_BUS_ADDRESS or XDG_RUNTIME_DIR.
chord-to-xdg-trigger = fn [chord str] any
Translates a Veko shortcut chord (e.g. 'Ctrl+Shift+Space') into an XDG GlobalShortcuts trigger string.
portal-open-file = fn [mut sh LinuxShellState, title str] str
Invokes org.freedesktop.portal.FileChooser.OpenFile (returns '' in headless/no-portal mode).
portal-save-file = fn [mut sh LinuxShellState, title str] str
Invokes org.freedesktop.portal.FileChooser.SaveFile (returns '' in headless/no-portal mode).
portal-notify = fn [mut sh LinuxShellState, title str, body str, tone enum] bool
Dispatches an XDG Desktop Notification (org.freedesktop.portal.Notification.AddNotification) and records it.
portal-register-shortcut = fn [mut sh LinuxShellState, chord str] any
Registers a global shortcut via org.freedesktop.portal.GlobalShortcuts.BindShortcuts.
portal-unregister-shortcut = fn [mut sh LinuxShellState, chord str] bool
Unregisters a global shortcut by chord string.
portal-decode-hotkey-id = fn [sh LinuxShellState, hk_id i64] str
Maps a registered hotkey ID back to its chord string (or '').
sni-tray-create = fn [mut sh LinuxShellState, tooltip str, menu_items block, click_action any] bool
Creates/registers an org.kde.StatusNotifierItem tray entry.
sni-tray-update = fn [mut sh LinuxShellState, tooltip str, menu_items block] bool
Updates the active StatusNotifierItem tooltip and menu items.
sni-tray-remove = fn [mut sh LinuxShellState]
Deactivates the StatusNotifierItem tray entry.
linux-shutdown-shell = fn [mut sh LinuxShellState]
Unregisters all global shortcuts and removes any active SNI tray item.