linux: switch systemd user service to type=notify-reload

This allows `systemctl` to send SIGUSR2 to Ghostty to trigger a reload,
which is more convenient than scripting `ps` and `kill` to find the
Ghostty main PID.
This commit is contained in:
Jeffrey C. Ollie
2025-07-04 15:01:54 -05:00
parent e18f16d94d
commit c9d0bbefc2
2 changed files with 14 additions and 1 deletions

View File

@ -1,9 +1,12 @@
[Unit]
Description=@NAME@
After=graphical-session.target
After=dbus.socket
Requires=dbus.socket
[Service]
Type=dbus
Type=notify-reload
ReloadSignal=SIGUSR2
BusName=@APPID@
ExecStart=@GHOSTTY@ --launched-from=systemd

View File

@ -29,6 +29,7 @@ const apprt = @import("../../apprt.zig");
const configpkg = @import("../../config.zig");
const input = @import("../../input.zig");
const internal_os = @import("../../os/main.zig");
const systemd = @import("../../os/systemd.zig");
const terminal = @import("../../terminal/main.zig");
const Config = configpkg.Config;
const CoreApp = @import("../../App.zig");
@ -1035,6 +1036,12 @@ pub fn reloadConfig(
target: apprt.action.Target,
opts: apprt.action.ReloadConfig,
) !void {
// Tell systemd that reloading has started.
systemd.notify.reloading();
// When we exit this function tell systemd that reloading has finished.
defer systemd.notify.ready();
if (opts.soft) {
switch (target) {
.app => try self.core_app.updateConfig(self, &self.config),
@ -1367,6 +1374,9 @@ pub fn run(self: *App) !void {
log.warn("error handling configuration changes err={}", .{err});
};
// Tell systemd that we are ready.
systemd.notify.ready();
while (self.running) {
_ = glib.MainContext.iteration(self.ctx, 1);