public sealed class PortalApplication The Linux provider of the application-scoped Runic.Platform services: XDG desktop portals, D-Bus services and freedesktop.org specifications, with one application identity and diagnostic sink for all of them.
Remarks
Configure once at application composition. Each service retains its own connection and lifetime; this object requires no disposal. A supplied host ID requires a matching installed desktop entry. Omitting the ID retains desktop-inferred identity for development or externally identified applications.
Windows and macOS have static providers (WindowsPlatformProvider, MacOSPlatformProvider) because their identity comes from the process: the AppUserModelID or the bundle. On Linux the portals identify the application by the desktop ID it registers once per connection, and report setup problems to the sink, so both live on this object.
Window services (file dialogs, the clipboard and file handoff) belong to a window: Runic's hosts create them for each window, such as DesktopPlatformServices.ForWindow of Runic.Application.Views.Desktop.
Constructors
PortalApplication
public PortalApplication(string? applicationId = null, Action<PortalDiagnostic>? diagnosticSink = null) Creates one identity configuration to use across all portal services.
Parameters
applicationIdThe installed reverse-DNS desktop ID, or null for desktop-inferred identity.
diagnosticSinkReceives setup messages for logs; see
PortalDiagnostic.
Exceptions
ArgumentExceptionapplicationIdis not a reverse-DNS D-Bus identifier.PlatformNotSupportedExceptionThe process does not run on Linux.
Properties
ApplicationId
public string? ApplicationId { get; } The installed reverse-DNS application identifier, or null for desktop-inferred identity.
Methods
CreateApplications
public IDesktopApplications CreateApplications() Creates the desktop's application database: content types, installed applications, default applications and icons, read from the freedesktop.org files.
Remarks
It needs no window and reads the XDG directories from the environment of this process when created. Only the icon theme lookup and D-Bus-activatable launches use the session bus. Inside Flatpak or Snap the host's applications are out of reach; content types and icons come from the sandbox's own data.
CreateGlobalShortcuts
public IDesktopGlobalShortcuts CreateGlobalShortcuts() Creates the application's global shortcuts through the desktop's GlobalShortcuts portal.
Remarks
The desktop owns the keys: DesktopGlobalShortcut.PreferredShortcut is a suggestion, the desktop may ask the user when the set is bound, and the user changes the keys in the desktop's settings (IDesktopGlobalShortcuts.ConfigureAsync opens them where the portal has version 2), which raises IDesktopGlobalShortcuts.BindingsChanged. The portal requires an application ID: outside Flatpak and Snap, pass this object the installed desktop ID. KDE Plasma 5.27 and later, GNOME 48 and later and Hyprland have a backend; elsewhere requests report PlatformUnavailableReason.BackendUnavailable and global-shortcuts-unavailable. Creating it connects to nothing; the first BindAsync does.
CreateInhibition
public IDesktopInhibition CreateInhibition() Creates application-scoped idle power inhibition, as the Windows and macOS providers do.
Remarks
Each request sends the empty parent window identifier, which the Inhibit portal accepts, so the request belongs to the application rather than to a window and works without one.
CreateLoginStartup
public IDesktopLoginStartup CreateLoginStartup() Creates login startup for this application. Nothing is registered until it is enabled.
Remarks
Outside a sandbox it writes ~/.config/autostart/<application ID>.desktop, so it needs the application ID; inside Flatpak or Snap it asks the Background portal, which may ask the user.
CreateNetworkStatus
public IDesktopNetworkStatus CreateNetworkStatus() Creates the computer's network status from the NetworkMonitor portal, or from NetworkManager where no portal answers.
Remarks
xdg-desktop-portal implements org.freedesktop.portal.NetworkMonitor itself, for sandboxed and unsandboxed applications alike: GetStatus from version 3 (available, metered and connectivity, whose local, limited, captive-portal and full levels map to DesktopNetworkConnectivity), the separate getters before, and its changed signal. Without a portal, such as under a minimal window manager, it reads NetworkManager's State, Connectivity and Metered on the system bus and follows their PropertiesChanged. When neither answers, reads report PlatformUnavailableReason.BackendUnavailable and the diagnostic network-monitor-unavailable.
A watch reports Unavailable when the portal or NetworkManager stops and a fresh state once one answers again. It needs no window and connects to nothing until the first request.
CreateNotifications
public IDesktopNotifications CreateNotifications() Creates application-scoped notifications; only one service may own this application bus name.
CreateOpenRegistration
public IDesktopOpenRegistration CreateOpenRegistration() Creates the registration of this application's URL schemes and file types with the desktop, for the current user.
Exceptions
InvalidOperationExceptionThis object has no
PortalApplication.ApplicationId, which names the entry.
Remarks
Outside a sandbox it writes the desktop entry $XDG_DATA_HOME/applications/<application ID>.desktop (Exec="<executable>" %U, MimeType= with x-scheme-handler/<scheme> and the file types, X-Runic-Registered=true) and, for a file type whose extension the shared MIME-info database does not give its DesktopFileType.MimeType, a definition in $XDG_DATA_HOME/mime/packages/<application ID>.xml, then runs update-mime-database and update-desktop-database where they are installed. A registration replaces the application's earlier one. A file type without a MIME type uses the database's type for its extension, PlatformFailureCode.InvalidData when it has none.
An entry of this ID that the application's package installed in XDG_DATA_DIRS, or one in XDG_DATA_HOME without the marker, is PlatformFailureCode.Conflict and reports open-registration-foreign-entry; nothing is written. Inside Flatpak or Snap, whose manifest exports the entry and MIME definitions, every request reports PlatformUnavailableReason.BackendUnavailable. It never sets a default (mimeapps.list).
CreatePowerEvents
public IDesktopPowerEvents CreatePowerEvents() Creates sleep, wake, session lock and battery events from logind, UPower and the power-profiles daemon.
Remarks
On the system bus: logind's PrepareForSleep is DesktopPowerEventKind.Suspending and DesktopPowerEventKind.Resumed; the process's session (GetSessionByPID, else the user's display session) gives Lock, Unlock and LockedHint, which lock screens set. UPower's OnBattery is DesktopPowerState.IsOnBattery, and the power-saver profile of org.freedesktop.UPower.PowerProfiles (or net.hadess.PowerProfiles) is DesktopPowerState.IsLowPower. Each source is optional; a value without one is null, and reads and watches are PlatformUnavailableReason.BackendUnavailable, with the diagnostic power-events-unavailable, only while none answers. A watch whose source's owner leaves reports Unavailable, reconnects after a few seconds and reports the current state; events in that gap are missed. Inside Flatpak the application needs --system-talk-name for each name.
Runic takes no logind delay lock, so the system does not wait for the application before it sleeps. It needs no window, works with either toolkit and without GTK, and connects to nothing until the first request.
CreateSecretStore
public IDesktopSecretStore CreateSecretStore() Creates secret storage in the desktop's Secret Service, such as GNOME Keyring or KeePassXC, or inside a sandbox without access to it in a file the Secret portal's secret encrypts.
Remarks
It needs no window and connects to nothing until the first request. Inside Flatpak the store uses the Secret Service when the sandbox allows talking to org.freedesktop.secrets, and inside Snap while the password-manager-service interface answers. Otherwise it keeps the secrets as libsecret does in a sandbox: in $XDG_DATA_HOME/keyrings/default.keyring, libsecret's file format, encrypted with a key derived from the application's secret from the Secret portal (org.freedesktop.portal.Secret), so libsecret-based code in the same sandbox shares the items. Without that portal requests report unavailable.
CreateSecretStore
public IDesktopSecretStore CreateSecretStore(DesktopSecretStoreOptions options) Creates secret storage in the desktop's Secret Service with options.
Exceptions
ArgumentNullExceptionoptionsisnull.
Remarks
The same choice of store as PortalApplication.CreateSecretStore. With DesktopSecretStoreOptions.RequireEncryption a Secret Service without the dh-ietf1024-sha256-aes128-cbc-pkcs7 algorithm fails each request with PlatformFailureCode.Other and the secret-service-encryption-required diagnostic instead of using a plain session; the Secret portal's file is always encrypted. With DesktopSecretStoreOptions.AllowUserInteraction false a Secret Service unlock or create prompt is dismissed unshown and the request is PlatformFailureCode.Locked; the Secret portal has no such flag, and its backend may ask once to unlock the login keyring. The macOS-only DesktopSecretStoreOptions.UseDataProtectionKeychain has no effect.
CreateSettings
public IDesktopSettings CreateSettings() Creates application-scoped appearance preferences.
CreateStatusIcon
public IDesktopStatusIcon CreateStatusIcon() Creates a status icon with a menu, registered with the desktop's StatusNotifierWatcher.
Remarks
Its Id is this application ID. Status icons have no portal: a sandbox must allow owning org.kde.StatusNotifierItem-* names and talking to org.kde.StatusNotifierWatcher.
CreateThumbnails
public IDesktopThumbnails CreateThumbnails() Creates thumbnails from the freedesktop.org thumbnail cache, and from the session's thumbnailer on a miss.
Remarks
It needs no window and reads the XDG directories from the environment of this process when created. On a cache miss it asks org.freedesktop.thumbnails.Thumbnailer1, such as Tumbler, on the session bus; GNOME and KDE run none, so there only thumbnails their file managers cached are returned. Inside Flatpak the sandbox must allow reading the host's cache (--filesystem=xdg-cache/thumbnails:ro) and talking to the thumbnailer.
CreateTrash
public IDesktopTrash CreateTrash() Creates the user's trash, following the freedesktop.org Trash specification.
Remarks
It needs no window. Outside a sandbox it moves items into $XDG_DATA_HOME/Trash, or into the trash at the top of the item's mount; inside Flatpak or Snap it asks the Trash portal.
CreateUnparentedFileDialogs
public IPickerBackend CreateUnparentedFileDialogs() Creates explicitly unparented file dialogs for an application without a window.
Remarks
Linux only: the portal may show such a dialog without a parent. Windows in a Runic host get dialogs owned by the window from the host instead.
CreateVolumes
public IDesktopVolumes CreateVolumes() Creates the desktop's storage volumes from UDisks2 on the system bus.
Remarks
UDisks2 asks Polkit for authorization itself and may show a prompt. The volumes need no portal and no window; a sandbox must allow talking to org.freedesktop.UDisks2 on the system bus. Creating them connects to nothing; the first request does.
ExportApplicationAsync
public ValueTask<PlatformResult<IAsyncDisposable>> ExportApplicationAsync(IApplicationInstance instance, CancellationToken cancellationToken = default) Serves D-Bus activation of the running instance: owns the application ID on the session bus and answers org.freedesktop.Application at the object path derived from it, as a desktop entry with DBusActivatable=true requires.
Parameters
instanceThe running instance from
ApplicationInstance.ClaimAsync. Each activation arrives as one of its launches:Activatewithout arguments,Openwith the URIs as arguments, which open requests created for the instance take, andActivateActionwith theExecarguments of the installed entry's[Desktop Action <name>](the action's parameter is not used). Theactivation-tokenordesktop-startup-idbecomes the launch'sApplicationLaunch.PlatformContext.cancellationTokenCancels before the name is owned.
Returns
The export, whose disposal releases the name; PlatformFailureCode.ResourceBusy, with dbus-activation-name-taken, when another process owns the application ID, and PlatformUnavailableReason.BackendUnavailable without a session bus.
Exceptions
InvalidOperationExceptionThis object has no
PortalApplication.ApplicationId.
Remarks
Call it once the instance is claimed, before the first window: the desktop starts a D-Bus-activatable application through its D-Bus service file and waits for the name. A call that comes while the instance is ending fails back to the caller. Notifications of this object share the name and the object path.