feat(flatpak): flatpak dynamic desktop entries, waypipe overhaul#1800
feat(flatpak): flatpak dynamic desktop entries, waypipe overhaul#1800brianmcgillion merged 3 commits intotiiuae:mainfrom
Conversation
Add a persistent Waypipe server as a systemd user service, replacing the previous approach of spawning a new Waypipe instance per app launch Apps now attach to the server automatically via WAYLAND_DISPLAY=wayland-ghaf. XWayland Satellite is optionally started as a systemd service for X11 support. Changes apply to all App VMs Signed-off-by: Kajus Naujokaitis <kajus.naujokaitis@unikie.com>
aa626c1 to
9eb1402
Compare
|
Waiting for reviews before asking for testing 🫡 |
|
Nice feature to integrate. 🙂 Just did a quick test on fresh install on Lenovo Gen12.
Mar 05 14:43:27 flatpak-vm flatpak-system-helper[1185]: system: Pulled app/com.spotify.Client/x86_64/stable from /var/lib/flatpak/repo/tmp/flatpak-cache-UPSIL3/repo-yLQaDI
Mar 05 14:43:27 flatpak-vm systemd[1]: Flatpak Share Installer was skipped because of an unmet condition check (ConditionDirectoryNotEmpty=/var/lib/flatpak/exports/share).
|
Add flatpak-apps-forwarder service to copy installed Flatpak app desktop entries to the Unsafe share, which is imported as an XDG profile in the gui-vm Exec fields are rewritten to route app launches through givc's flatpak-run 'app' which runs 'flatpak run <app-id>' in flatpak-vm Signed-off-by: Kajus Naujokaitis <kajus.naujokaitis@unikie.com>
9eb1402 to
a265646
Compare
Thanks for testing! |
Add "Force Quit" and "Uninstall" desktop entry actions to all installed flatpak apps. Allows the user to kill, or uninstall the given application easily via GUI Signed-off-by: Kajus Naujokaitis <kajus.naujokaitis@unikie.com>
|
New feature: Also did some minor refactoring as a consequence of this Note: It seems that at the moment these actions don't appear to function in the COSMIC App Library, but work fine if the app is already open and right-clicked in the Dock. Seems like a COSMIC bug at first glance. |
|
Waypipe instances One per app launch Single persistent server - I think that this goes against the wayland approach to keeping apps separate to ensure they do not interfer with each other. this is the X11 way :) |
Description of Changes
TL;DR
flatpak run1. Flatpak Desktop Entry Export
Flatpak app desktop entries installed in the Flatpak VM are automatically exported to the GUI VM, where they appear in the app library and can be launched like any other app.
How the export works:
flatpak-share-installer) watches for installed Flatpak apps and copies the flatpakexports/sharedir (which includes the desktop entries and icons) to the Unsafe share (/home/appuser/Unsafe share/.flatpak-share)These are mostly icons (svg or png),
.desktopentries, and some metainfo files.environment.profiles, making the entries visible to the DEExec=field is rewritten to route the launch through givc'sflatpak-runcommand, which (basically) triggersflatpak run <app-id>in the Flatpak VMflatpak-rungivc app actually reads the real desktop entry for the given app-id and executes that in Flatpak VM.Note
If a Flatpak app is installed that duplicates an app already provided by us (e.g. Element, which is also provided via comms-vm), both entries will appear in the app library.
The Flatpak entry will show its source as "unknown", while the system-provided entry will correctly show "Nix" as its source.
This is a known limitation of the (un)intelligent source-detection logic in the
freedesktop-desktop-entrycrate, which is used bycosmic-app-library.Desktop Entries' Export Visualized
flowchart LR subgraph FLATPAK_VM["Flatpak VM"] INSTALLED["installed flatpak apps"] EXPORTER["flatpak-share-installer"] EDITED["desktop entries with rewritten Exec="] SHARE["Unsafe flatpak-vm share"] INSTALLED --> EXPORTER --> EDITED --> SHARE end subgraph GUI_VM["GUI VM"] PROFILES["environment.profiles adds share as XDG profile"] APPLIBRARY["app appears in app library"] SHARE --> PROFILES --> APPLIBRARY endFlatpak App Launch Flowchart
flowchart LR USER["user clicks desktop entry"] EXEC["Exec= runs ghaf-open flatpak-run with http://app.id"] GIVC_GUI["givc in GUI VM"] GIVC_FLATPAK["givc in Flatpak VM"] RUN["run-flatpak-app"] APP["app starts in Flatpak VM"] USER --> EXEC EXEC --> GIVC_GUI GIVC_GUI -- "flatpak-run url=http://app.id" --> GIVC_FLATPAK GIVC_FLATPAK --> RUN --> APP2. Persistent Waypipe Server
Previously, a new Waypipe server instance was spawned for every app launch, requiring
run-waypipeto be explicitly prefixed to each givc app definition. This made launching apps across VMs unintuitive, as it was unclear which environment variables (WAYLAND_DISPLAY,DISPLAY,XDG_SESSION_TYPE, etc.) needed to be set for which app. Running multiple apps simultaneously also meant multiple Waypipe server instances running at the same time unnecessarily.What changed:
$XDG_RUNTIME_DIR/wayland-ghafWAYLAND_DISPLAY=wayland-ghafDISPLAY=:99The following environment variables are set in the AppUser session:
Side-by-side Comparison
run-waypipeRestart=on-failureto recoverOld Approach Flowchart
flowchart TB subgraph BEFORE["BEFORE"] direction TB subgraph GUIVM_OLD["GUI VM"] CLIENT_OLD["waypipe client <- compositor"] end subgraph APPVM_OLD["App VM (flatpak)"] SP["Spotify"] DI["Discord (X11)"] WP1["waypipe server #1"] WP2["waypipe server #2"] VSOCK["vsock"] SP --> WP1 --> VSOCK DI --> WP2 --> VSOCK end VSOCK --> CLIENT_OLD endNew Approach Flowchart
flowchart TB subgraph AFTER["AFTER"] direction TB subgraph GUIVM_NEW["GUI VM"] CLIENT_NEW["waypipe client <- compositor"] end subgraph APPVM_NEW["App VM (flatpak)"] SERVER["waypipe server (systemd) (+ optional xwayland-satellite)"] VSOCK["vsock"] SP["Spotify"] DI["Discord (X11)"] SP -- "WAYLAND_DISPLAY=wayland-ghaf" --> SERVER DI -- "DISPLAY=:99" --> SERVER end SERVER --> VSOCK --> CLIENT_NEW endNote
Flatpak VM is used heavily as an example here, but note that the waypipe overhaul applies to ALL App VMs
Type of Change
Related Issues / Tickets
Checklist
make-checksand it passesTesting Instructions
Applicable Targets
aarch64aarch64x86_64x86_64x86_64Installation Method
nixos-rebuild ... switchTest Steps To Verify:
Flatpak app desktop entries:
Flatpak app launching:
Regression: