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 <leorize+oss@disroot.org>
This commit is contained in:
Jeffrey C. Ollie
2025-06-24 23:28:04 -05:00
committed by Mitchell Hashimoto
parent 81403f59ce
commit ddada2fb3f
3 changed files with 27 additions and 16 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application"> <component type="desktop-application">
<id>com.mitchellh.ghostty</id> <id>com.mitchellh.ghostty@@DEBUG@@</id>
<launchable type="desktop-id">com.mitchellh.ghostty.desktop</launchable> <launchable type="desktop-id">com.mitchellh.ghostty@@DEBUG@@.desktop</launchable>
<name>Ghostty</name> <name>Ghostty</name>
<url type="homepage">https://ghostty.org</url> <url type="homepage">https://ghostty.org</url>
<url type="help">https://ghostty.org/docs</url> <url type="help">https://ghostty.org/docs</url>

View File

@ -6,11 +6,7 @@ sdk-extensions:
- org.freedesktop.Sdk.Extension.ziglang - org.freedesktop.Sdk.Extension.ziglang
default-branch: tip default-branch: tip
command: ghostty 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 rename-icon: com.mitchellh.ghostty
desktop-file-name-suffix: " (Debug)"
finish-args: finish-args:
# 3D rendering # 3D rendering
- --device=dri - --device=dri

View File

@ -258,15 +258,34 @@ pub fn init(b: *std.Build, cfg: *const Config) !GhosttyResources {
), ),
); );
// systemd user service // 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( try steps.append(
formatService( formatService(
b, b,
cfg, cfg,
b.path("dist/linux/systemd.service"), b.path("dist/linux/com.mitchellh.ghostty.metainfo.xml"),
b.fmt( 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) { switch (cfg.optimize) {
.Debug, .ReleaseSafe => "-debug", .Debug, .ReleaseSafe => "-debug",
.ReleaseFast, .ReleaseSmall => "", .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 // Right click menu action for Plasma desktop
try steps.append(&b.addInstallFile( try steps.append(&b.addInstallFile(
b.path("dist/linux/ghostty_dolphin.desktop"), 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", "-e s!@@NAME@@!{s}!g",
.{ .{
switch (cfg.optimize) { switch (cfg.optimize) {
.Debug, .ReleaseSafe => " Debug", .Debug, .ReleaseSafe => " (Debug)",
.ReleaseFast, .ReleaseSmall => "", .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", "-e s!@@GHOSTTY@@!{s}/bin/ghostty!g",
.{b.install_prefix}, .{b.install_prefix},
)); ));
if (cfg.flatpak)
cmd.addArg("-e /^SystemdService=/d");
return &b.addInstallFile(output, dest).step; return &b.addInstallFile(output, dest).step;
} }