Documents
Flatpak Theme Integration
Flatpak Theme Integration
Type
Topic
Status
Published
Created
Apr 15, 2026
Updated
Apr 15, 2026
Created by
Dosu Bot
Updated by
Dosu Bot

Flatpak Theme Integration#

Flatpak sandboxing prevents apps from directly reading host theme files and DConf settings. Instead, system appearance preferences flow through three standardized layers:

  1. AdwStyleManager (libadwaita) — the in-process API for controlling and querying an app's color scheme
  2. XDG Desktop Portal / Settings portal — the IPC bridge that exposes host appearance settings (org.freedesktop.appearance color-scheme) into the sandbox
  3. Flatpak theme extensions — the packaging model for distributing GTK themes without weakening sandbox permissions
LayerScopePrimary Standard
AdwStyleManagerPer-app color scheme controllibadwaita API
Settings portalSystem preference → sandboxXDG Desktop Portal
Theme extensionsGTK theme distributionFlatpak extension spec

AdwStyleManager — libadwaita's Color Scheme API#

AdwStyleManager is the canonical API for GNOME apps to manage light/dark appearance. Retrieve the singleton via adw_style_manager_get_default() or per-display via adw_style_manager_get_for_display().

Key methods:

MethodPurpose
get_color_scheme() / set_color_scheme()Get or set the requested AdwColorScheme
get_dark()Whether the app is currently rendering dark (computed from scheme + system)
get_system_supports_color_schemes()Whether the running system exposes a color-scheme preference
get_accent_color_rgba()Current system accent color (libadwaita ≥ 1.6)
get_system_supports_accent_colors()Whether accent colors are supported (libadwaita ≥ 1.6)

AdwColorScheme values include DEFAULT, FORCE_LIGHT, FORCE_DARK, PREFER_LIGHT, and PREFER_DARK — the PREFER_* variants follow the system setting while expressing a fallback preference.

GNOME HIG guidance : most apps should use light by default and follow the system-wide style. When exposing a per-app preference, always offer three options: Light, Dark, and Follow System. Per-app style controls are primarily justified for text editors or apps used for extended periods.

The GNOME dark mode tutorial walks through wiring AdwStyleManager to a GAction + GSettings so the preference persists across sessions.

XDG Desktop Portal: Bridging Host Preferences into the Sandbox#

Because the Flatpak sandbox blocks direct DConf/GSettings access to the host, system appearance settings reach sandboxed apps via the XDG Desktop Portal :

  • Wayland: the active theme and org.freedesktop.appearance color-scheme value are exposed through the Settings portal. A matching desktop-environment portal backend (e.g., xdg-desktop-portal-gnome) must be installed.
  • X11: GTK3 reads theme info from the XSettings daemon (gsd-xsettings), which itself reads DConf values from the host.

If no portal backend is present or the theme is unavailable inside the sandbox, GTK apps fall back to Adwaita default. libadwaita apps still respond correctly to the color-scheme value provided through the portal, so dark/light switching works automatically without any extra permissions when the portal is in place.

Flatpak Theme Extensions and Flathub Packaging Rules#

GTK themes that need to be applied inside a Flatpak sandbox must be packaged as Flatpak extensions, not through direct filesystem access. Requesting --filesystem=~/.themes in a manifest's finish-args triggers the Flathub linter error finish-args-incorrect-theme-folder-permission and will block submission. The linter guidance points to the Flatpak desktop integration docs as the canonical reference.

Two accepted packaging patterns:

PatternWhen to use
Standard Flatpak extensionActively maintained themes
Unmaintained GTK theme extensionLegacy / low-activity themes

Extension ID rule: a theme extension's ID must be prefixed with the extension point ID (defined in a runtime or parent app).

For apps built on libadwaita, custom GTK themes are largely unnecessary — AdwStyleManager handles light/dark switching natively using the built-in Adwaita style, and libadwaita CSS variables and style classes automatically adapt to light, dark, and high-contrast appearances .

Flatpak Theme Integration | Dosu