Skip to content
  1. Docs
  2. enzUI framework
  3. Developers

Desktop services

Portals, opening files and links, clipboard, notifications, single instance, tray, persistence, credentials and other capabilities that are not widgets.

Beyond widgets, enzUI provides models, services and platform integrations an app calls directly. Most live in enzui-core and enzui-services, each heavy backend behind a feature (see Project layout and features). The repository's docs/core-capabilities.md is the full keyword index: search it by intent ("hotkey", "remember window size", "store a password") before writing your own.

Portals

enzui_core::portal is a portal-first layer over the XDG Desktop Portal, with typed lifecycle outcomes for each operation. The D-Bus backend (feature portal-dbus, forwarded by enzui-widgets) activates an installed portal asynchronously, and the app's portal code does not depend on GTK, GDK or libadwaita: the host's portal service can be implemented by any toolkit. When no portal service answers, calls return a typed unavailable result rather than failing silently.

Portal modules cover the file chooser, opening URIs and files, notifications, printing, screenshots, screen casting through PipeWire, global shortcuts, background permission and inhibiting idle or logout. Dialogs are parented to the app's window through portal::parent: an xdg-foreign export on Wayland, an x11: window id on X11.

  • File chooser. file_chooser::ChooserSession holds a lazily initialized backend and one tagged request. Start it on a user gesture, include its subscription, and call pump on a chooser wake; a completed result gives the chosen files with result.local_paths(). An in-app chooser stands in when no portal answers. cancel(CancelReason) settles a request at once; use ParentClosed when its window closes. When a chooser cannot run, file_chooser::failure_text(&outcome) is the translated message to show.
  • Opening links and files. portal::open_uri opens a URI or file with the desktop's default handler: the launcher for a native process, the portal inside a sandbox.
rust
let uri = OpenUri::parse("https://iced.rs").unwrap();
let started = OpenUriRequest::new(uri, PortalParent::None)
    .start(&mut *self.launcher, |_| true);

OpenFileRequest::containing_folder(file, parent) shows a file in its folder in the file manager.

  • Portal results are URIs. Convert with FileUri::to_path and handle failures, rather than stripping file:// yourself.

Clipboard and drag and drop

On Wayland, app_setup::run installs enzui-clipboard on the application's own connection: text, HTML, images (with enzui-clipboard-runtime/image) and file lists. Fields offer the primary selection and paste it on a middle click. When the app exits, what it still owns is handed to a keeper so it survives where the compositor offers ext_data_control_v1. On X11 the runtime's default clipboard is used. ENZUI_CLIPBOARD=default keeps iced's provider on Wayland too.

Native drag and drop with other applications is on Drag and drop.

Desktop settings

enzui_core::desktop_settings reads what the desktop says about button layout, accent colour, contrast, clock format and fonts, from GTK's settings.ini and, with portal-dbus, the Settings portal and its change signal. app_setup::run starts the watcher, and widgets follow it on their own.

  • Launch arguments. enzui_core::activation::launch_request reads a launch's arguments into a LaunchRequest: files become absolute file:// URIs, URIs stay, and the intent is Open or Activate.
  • Single instance. single_instance::SingleInstance::start(app_id) (feature application-dbus) owns the application or forwards a second launch's files to it. See Packaging.
  • D-Bus activation. enzui_core::activation::dbus::ApplicationService::connect(id) serves org.freedesktop.Application, so launchers and notification actions can start or reach the app.
  • Search. ApplicationService::serve_search answers the desktop's search over GNOME Shell's and KRunner's interfaces as well as enzUI's.
  • Activation tokens. Raising a window uses XDG_ACTIVATION_TOKEN on Wayland and DESKTOP_STARTUP_ID on X11.

Notifications, tray and launcher

  • Desktop notifications go through the notification portal, or through org.freedesktop.Notifications outside a sandbox (feature notification-freedesktop), with actions, replacement and withdrawal. They are attributed to the app's id.
  • Tray icon: enzui_core::tray::Tray with TrayItem, TrayIcon and a menu (feature shell-integration). It needs a StatusNotifierItem host: KDE, the GNOME AppIndicator extension, or waybar.
  • Launcher badge: enzui_core::launcher_badge::LauncherBadge sets a count and urgent mark on the app's launcher entry.
  • Dock progress: enzui-activity publishes background activity, and emits the standard com.canonical.Unity.LauncherEntry progress signal when its own socket is unreachable.

Persisting state and credentials

  • enzui_core::persist::Store saves a typed value through a FileBackend (for example FileBackend::xdg(..) under $XDG_CONFIG_HOME) with an explicit RawByteLimit. Loads report loaded, absent, refused and malformed state distinctly, and a failed load never authorizes overwriting the file. Saves are atomic.
  • Credentials: enzui_services::credential_store::connect_for_app (features secret-service, secret-portal) uses the Secret Service on a desktop. Inside a sandbox it seals a keyring file in the app's data directory with the Secret portal's per-app secret.
  • OAuth: enzui_services::oauth (feature oauth) runs the authorization code flow with PKCE through the system browser.

Windows and the compositor

Some Wayland services require support from the compositor.

CapabilityAPI
Monitorsiced::window::Monitor
The desktop's alert sound or flashsystem_bell (xdg_system_bell_v1)
A window iconthrough xdg_toplevel_icon_v1
Session restore: the window comes back where it waswindow_placement::session::WindowSession (xdg-session-management)
Content type and tearing hintssurface_hints (wp_content_type_v1, wp_tearing_control_v1)
A notice after a crashcrash_report::CrashReporter and crash_notice::enz_crash_notice

Several windows in one process use window_lifecycle::WindowLedger to decide when to exit.

Media, documents and more

NeedWhere
Audio and video playback, event soundsenzui-services, feature gstreamer
Media keys and desktop media controlsenzui-services, feature mpris
PDF thumbnails and video poster framesenzui_services::document_preview (pdf-preview, gstreamer)
Writing a PDF for printing or exportprint_pdf::PdfDocument
Spell checkingenzui_services::spell_check (feature spell-check)
Archive extractionfeature archive
Git repository status, read without running Gitenzui_services::vcs
The freedesktop thumbnail cacheenzui-core, feature thumbnail-cache
Freedesktop icon themesenzui-services, feature desktop-icons
Downloadsenzui_core::download and enz_download_list
Mail transport (SMTP, IMAP)enzui-services, feature mail-transport
A terminalthe enzui-terminal crate

Named, discoverable commands are enzui_core::Action values (label, icon, shortcut, enabled state). Menus, the command palette, toolbars and the shortcut dispatcher all consume them, so model commands as actions rather than bare closures.