From ddada2fb3fb7740a8b560cd96403cf06946c5d89 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Tue, 24 Jun 2025 23:28:04 -0500 Subject: [PATCH] flatpak: remove references to systemd unit Replaces #7676 When building as a flatpak, don't install the systemd user services since flatpaks can't use them. Remove references to the systemd service from the DBus service. Also, customize the app metadata depending on the debug mode. Co-authored-by: Leorize --- dist/linux/com.mitchellh.ghostty.metainfo.xml | 4 +-- flatpak/com.mitchellh.ghostty-debug.yml | 4 --- src/build/GhosttyResources.zig | 35 +++++++++++++------ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/dist/linux/com.mitchellh.ghostty.metainfo.xml b/dist/linux/com.mitchellh.ghostty.metainfo.xml index 0424d3a09..46b370bb8 100644 --- a/dist/linux/com.mitchellh.ghostty.metainfo.xml +++ b/dist/linux/com.mitchellh.ghostty.metainfo.xml @@ -1,7 +1,7 @@ - com.mitchellh.ghostty - com.mitchellh.ghostty.desktop + com.mitchellh.ghostty@@DEBUG@@ + com.mitchellh.ghostty@@DEBUG@@.desktop Ghostty https://ghostty.org https://ghostty.org/docs diff --git a/flatpak/com.mitchellh.ghostty-debug.yml b/flatpak/com.mitchellh.ghostty-debug.yml index 8a2c0056e..fe4722ef5 100644 --- a/flatpak/com.mitchellh.ghostty-debug.yml +++ b/flatpak/com.mitchellh.ghostty-debug.yml @@ -6,11 +6,7 @@ sdk-extensions: - org.freedesktop.Sdk.Extension.ziglang default-branch: tip command: ghostty -# Integrate the rename into zig build, maybe? -rename-desktop-file: com.mitchellh.ghostty.desktop -rename-appdata-file: com.mitchellh.ghostty.metainfo.xml rename-icon: com.mitchellh.ghostty -desktop-file-name-suffix: " (Debug)" finish-args: # 3D rendering - --device=dri diff --git a/src/build/GhosttyResources.zig b/src/build/GhosttyResources.zig index f3b169de1..f72006b4b 100644 --- a/src/build/GhosttyResources.zig +++ b/src/build/GhosttyResources.zig @@ -258,15 +258,34 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources { ), ); // systemd user service + if (!cfg.flatpak) + try steps.append( + formatService( + b, + cfg, + b.path("dist/linux/systemd.service"), + b.fmt( + "{s}/systemd/user/com.mitchellh.ghostty{s}.service", + .{ + if (cfg.system_package) "lib" else "share", + switch (cfg.optimize) { + .Debug, .ReleaseSafe => "-debug", + .ReleaseFast, .ReleaseSmall => "", + }, + }, + ), + ), + ); + + // AppStream metainfo so that application has rich metadata within app stores try steps.append( formatService( b, cfg, - b.path("dist/linux/systemd.service"), + b.path("dist/linux/com.mitchellh.ghostty.metainfo.xml"), b.fmt( - "{s}/systemd/user/com.mitchellh.ghostty{s}.service", + "share/metainfo/com.mitchellh.ghostty{s}.metainfo.xml", .{ - if (cfg.system_package) "lib" else "share", switch (cfg.optimize) { .Debug, .ReleaseSafe => "-debug", .ReleaseFast, .ReleaseSmall => "", @@ -276,12 +295,6 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources { ), ); - // AppStream metainfo so that application has rich metadata within app stores - try steps.append(&b.addInstallFile( - b.path("dist/linux/com.mitchellh.ghostty.metainfo.xml"), - "share/metainfo/com.mitchellh.ghostty.metainfo.xml", - ).step); - // Right click menu action for Plasma desktop try steps.append(&b.addInstallFile( b.path("dist/linux/ghostty_dolphin.desktop"), @@ -360,7 +373,7 @@ pub fn formatService(b: *std.Build, cfg: *const Config, src: std.Build.LazyPath, "-e s!@@NAME@@!{s}!g", .{ switch (cfg.optimize) { - .Debug, .ReleaseSafe => " Debug", + .Debug, .ReleaseSafe => " (Debug)", .ReleaseFast, .ReleaseSmall => "", }, }, @@ -378,6 +391,8 @@ pub fn formatService(b: *std.Build, cfg: *const Config, src: std.Build.LazyPath, "-e s!@@GHOSTTY@@!{s}/bin/ghostty!g", .{b.install_prefix}, )); + if (cfg.flatpak) + cmd.addArg("-e /^SystemdService=/d"); return &b.addInstallFile(output, dest).step; }