From 959b2c8d7f6d6e99a969c9b54d0d3af753cd9d41 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Wed, 16 Jul 2025 10:53:19 -0500 Subject: [PATCH] linux/systemd: add comments explaining need for app- prefix --- src/build/GhosttyResources.zig | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/build/GhosttyResources.zig b/src/build/GhosttyResources.zig index 02f3230af..ca95dbbb3 100644 --- a/src/build/GhosttyResources.zig +++ b/src/build/GhosttyResources.zig @@ -283,13 +283,23 @@ fn addLinuxAppResources( b.fmt("share/dbus-1/services/{s}.service", .{app_id}), }); - // systemd user service. This is kind of nasty but systemd - // looks for user services in different paths depending on - // if we are installed as a system package or not (lib vs. - // share) so we have to handle that here. We might be able - // to get away with always installing to both because it - // only ever searches in one... but I don't want to do that hack - // until we have to. + // `systemd` user service. This is kind of nasty but `systemd` looks for + // user services in different paths depending on if we are installed + // as a system package or not (lib vs. share) so we have to handle that + // here. We might be able to get away with always installing to both + // because it only ever searches in one... but I don't want to do that + // hack until we have to. + // + // The XDG Freedesktop Portal has a major undocumented requirement + // for programs that are launched/controlled by `systemd` to interact + // with the Portal. The unit must be named `app-.service`. The + // Portal uses the `systemd` unit name figure out what the program's + // application ID is and it will only look at unit names that begin with + // `app-`. I can find no place that this is documented other than by + // inspecting the code or the issue and PR that introduced this feature. + // See the following code: + // + // https://github.com/flatpak/xdg-desktop-portal/blob/7d4d48cf079147c8887da17ec6c3954acd5a285c/src/xdp-utils.c#L152-L220 if (!cfg.flatpak) try ts.append(.{ b.path("dist/linux/systemd.service.in"), b.fmt(