mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-13 15:26:09 +03:00
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:
5
dist/linux/systemd.service.in
vendored
5
dist/linux/systemd.service.in
vendored
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user