Add Flatpak support for Linux#185
Open
candrewlee14 wants to merge 6 commits intoblackboardsh:mainfrom
Open
Conversation
Native wrapper (nativeWrapper.cpp):
- Respect XDG_CACHE_HOME/XDG_DATA_HOME/XDG_RUNTIME_DIR instead of
hardcoding ~/.cache and ~/.local/share paths
- Replace gtk_file_chooser_dialog_new with GtkFileChooserNative so file
choosers route through org.freedesktop.portal.FileChooser in sandbox
- Replace system("xdg-open"/"gio open") in openFileManager with
g_app_info_launch_default_for_uri (portal-aware GIO)
- Remove system("xdg-open") fallback in openURL/openPath
- Replace system("notify-send") with org.freedesktop.portal.Notification
D-Bus call so notifications work inside Flatpak sandbox
- Use theme icon name (FLATPAK_ID) for tray icon when running in Flatpak
so the host compositor can resolve the icon
CLI (cli/index.ts):
- Add linux.flatpak config section (enabled, runtimeVersion, categories,
extraFinishArgs)
- Add generateFlatpakManifest(), generateFlatpakDesktopFile(),
generateFlatpakAppdata() helpers
- Add createFlatpakBundle() which runs flatpak-builder + flatpak
build-bundle to produce a .flatpak artifact when flatpak.enabled is set
mise.toml:
- Add cmake as a managed tool dependency for the Linux native wrapper build
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
6a83595 to
f8e6d02
Compare
nativeWrapper.cpp: - Add getXdgRuntimeDir() helper with correct /tmp fallback (fixes bug where XDG_RUNTIME_DIR unset resolved to $HOME/tmp instead of /tmp) - Use per-notification atomic counter ID so rapid notifications don't overwrite each other - Fix setImage() to use theme icon name inside Flatpak (same logic as the constructor — was using raw absolute path before) - Restore xdg-open fallback in openExternal/openPath for non-Flatpak environments where GIO may not have a handler registered cli/index.ts: - Add xmlEscape() helper; use it throughout generateFlatpakAppdata() - Validate app ID is reverse-DNS format before writing YAML manifest - Validate extraFinishArgs entries contain no newlines - Fix --talk-name: org.freedesktop.portal.Desktop (not the legacy org.freedesktop.Notifications libnotify bus) - Add metainfo install command to manifest build-commands so the AppStream file is actually bundled - Add mkdirSync for flatpakBuildDir so --repo path parent exists - Add StartupWMClass to .desktop file for consistency - Wrap createFlatpakBundle() call in try/catch so a build failure doesn't leave the app bundle folder behind Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Switch collectExtraLibs() from ldd (full transitive closure) to readelf -d (direct DT_NEEDED only) with ldconfig -p for path resolution. Recurse only into non-runtime libs, stopping at GTK/GLib/OpenSSL/WebKit deps that the org.gnome.Platform runtime already provides. This avoids bundling ~100 libs from the host that conflict with the runtime's own matched versions (e.g. libcrypto.so.3 from Fedora conflicting with the Ubuntu-built libssl.so.3 in the GNOME runtime). Result: 5 libs bundled (ayatana appindicator stack + libasar) instead of 109. Also expand the runtime prefix exclusion list to cover OpenSSL, GnuTLS, Kerberos, GStreamer, ICU, image codecs, and other GNOME runtime libs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The native wrapper forces GDK_BACKEND=x11 before gtk_init, so the app runs as an X11 app under XWayland. --socket=fallback-x11 only provides the X11 socket when there is no Wayland compositor, so on a Wayland session DISPLAY was never set and the app silently failed to launch from the app launcher. --socket=x11 always sets up XWayland and DISPLAY. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When CEF is absent, remove the GDK_BACKEND=x11 override so GTK initialises natively on Wayland. CEF has no native Wayland support so the override is kept when CEF is present. Also guard XSetErrorHandler behind a GDK_IS_X11_DISPLAY() check — the Wayland GDK backend handles protocol errors internally and has no equivalent global error hook. All gdk_x11_get_default_xdisplay() calls in the codebase are inside CEF-only code paths so they are unaffected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
@YoavCodes I did some manual testing here on getting the flatpak running, and all the browser tests passed on it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds end-to-end Flatpak support for Linux builds.
What's in here
Native wrapper (
nativeWrapper.cpp)GtkFileChooserNativeso they route throughorg.freedesktop.portal.FileChooserin the sandboxopenFileManager()usesg_app_info_launch_default_for_uri()(GIO/portal-aware) instead ofsystem("xdg-open ...")openURL()drops thesystem()fallback — it doesn't work inside a sandbox anywayshowNotification()callsorg.freedesktop.portal.Notificationover D-Bus instead ofsystem("notify-send ...")$FLATPAK_ID) when running inside Flatpak, so the host compositor can find itXDG_CACHE_HOME,XDG_DATA_HOME,XDG_RUNTIME_DIR) take precedence over hardcoded~/.cacheetc.CLI (
cli/index.ts)flatpakconfig section underbuild.linux:enabled,runtimeVersion,categories,extraFinishArgscreateFlatpakBundle()generates a Flatpak manifest,.desktopfile, and AppStream metainfo, then runsflatpak-builderandflatpak build-bundleto produce a.flatpakartifactorg.gnome.Platform(includeslibwebkit2gtk-4.1) with default runtime version"48"collectExtraLibs()usesreadelf -d+ldconfig -pto walk the dep tree oflibNativeWrapper.so, bundling only libs not provided by the runtime (in practice: the ayatana appindicator stack). Uses direct DT_NEEDED edges rather thanldd's full transitive closure to avoid pulling in WebKit's ~100 deps and hitting ABI version conflicts with the runtime's own copies.flatpak/flatpak-builderaren't installedKitchen config
flatpak.enabled: trueadded as a live example and to keep the feature testedRuntime requirements (build host)
flatpakandflatpak-builderreadelf(binutils)org.gnome.Platform//48andorg.gnome.Sdk//48installed via Flathub🤖 Generated with Claude Code