Skip to content

linux/systemd: add an app- prefix to the systemd unit#7959

Merged
jcollie merged 2 commits intoghostty-org:mainfrom
jcollie:systemd-unit-app-prefix
Jul 16, 2025
Merged

linux/systemd: add an app- prefix to the systemd unit#7959
jcollie merged 2 commits intoghostty-org:mainfrom
jcollie:systemd-unit-app-prefix

Conversation

@jcollie
Copy link
Copy Markdown
Member

@jcollie jcollie commented Jul 16, 2025

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-<appid>.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

This may fix many people's issues with getting global shortcuts
to work.

Note that this is a breaking change if you have been using Ghostty
compiled from source since #7433 was merged. You will need to ensure
that any Ghosty systemd unit files not prefixed with app- are
deleted.

Original discussion/PR in the XDG Desktop Portal repository:

flatpak/xdg-desktop-portal#579
flatpak/xdg-desktop-portal#719

Originally discussed on Discord:

https://discord.com/channels/1005603569187160125/1394845362186879026

Co-authored-by: ambareeshbalaji@gmail.com

@jcollie jcollie requested a review from a team as a code owner July 16, 2025 14:51
@jcollie
Copy link
Copy Markdown
Member Author

jcollie commented Jul 16, 2025

cc @pluiedev @ambyjkl

@jcollie
Copy link
Copy Markdown
Member Author

jcollie commented Jul 16, 2025

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-<appid>.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

This may fix many people's issues with getting global shortcuts
to work.

Note that this is a breaking change if you have been using Ghostty
compiled from source since ghostty-org#7433 was merged. You will need to ensure
that any Ghosty systemd unit files _not_ prefixed with `app-` are
deleted.

Original discussion/PR in the XDG Desktop Portal repository:

flatpak/xdg-desktop-portal#579
flatpak/xdg-desktop-portal#719

Originally discussed on Discord:

https://discord.com/channels/1005603569187160125/1394845362186879026

Co-authored-by: ambareeshbalaji@gmail.com
@jcollie jcollie force-pushed the systemd-unit-app-prefix branch from 0a0a03d to 2435cee Compare July 16, 2025 15:28
Copy link
Copy Markdown
Member

@pluiedev pluiedev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we want to leave a comment in the Zig code explaining exactly why this is, but this by itself already LGTM

Copy link
Copy Markdown
Member

@tristan957 tristan957 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Copy link
Copy Markdown
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, nice comment. I think we should add a shorter comment to the unit file too just pointing people to maybe our build scripts to learn more, just for future people who may touch those files.

Comment thread dist/linux/dbus.service.in
@jcollie jcollie force-pushed the systemd-unit-app-prefix branch 2 times, most recently from 3c74648 to 959b2c8 Compare July 16, 2025 16:24
@jcollie jcollie merged commit 50a88dc into ghostty-org:main Jul 16, 2025
76 checks passed
@jcollie jcollie deleted the systemd-unit-app-prefix branch July 16, 2025 16:48
@github-actions github-actions Bot added this to the 1.2.0 milestone Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants