diff --git a/include/ghostty.h b/include/ghostty.h index b413dec41..12eb26840 100644 --- a/include/ghostty.h +++ b/include/ghostty.h @@ -12,6 +12,7 @@ extern "C" { #endif +#include #include #include #include diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 603523e80..d1f12ad0f 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -108,7 +108,13 @@ class AppDelegate: NSObject, // Initial config loading configDidReload(ghostty) - + + updaterController.updater.updateCheckInterval = 60 + updaterController.updater.automaticallyChecksForUpdates = + ghostty.config.autoUpdates == "check" || ghostty.config.autoUpdates == "download" + updaterController.updater.automaticallyDownloadsUpdates = + ghostty.config.autoUpdates == "download" + // Register our service provider. This must happen after everything is initialized. NSApp.servicesProvider = ServiceProvider() diff --git a/macos/Sources/Ghostty/Ghostty.Config.swift b/macos/Sources/Ghostty/Ghostty.Config.swift index e917bf2c0..4ddb986f9 100644 --- a/macos/Sources/Ghostty/Ghostty.Config.swift +++ b/macos/Sources/Ghostty/Ghostty.Config.swift @@ -360,6 +360,17 @@ extension Ghostty { _ = ghostty_config_get(config, &v, key, UInt(key.count)) return v; } + + var autoUpdates: String { + let defaultValue = "off" + guard let config = self.config else { return defaultValue } + let key = "auto-updates" + + var value: UnsafePointer? = nil + guard ghostty_config_get(config, &value, key, UInt(key.count)) else { return defaultValue } + guard let pointer = value else { return defaultValue } + return String(cString: pointer) + } } } diff --git a/src/config/Config.zig b/src/config/Config.zig index d853f0481..b9217d0e3 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -1462,6 +1462,13 @@ term: []const u8 = "xterm-ghostty", /// running. Defaults to an empty string if not set. @"enquiry-response": []const u8 = "", +/// This controls the automatic update functionality on macOS by setting the +/// properties on the Squirrel automatic update component. By default this is +/// set to "off" which doesn't do anything. The "check" option will automatically +/// check for updates but will NOT download them, while as the "download" option +/// will both check AND download updates automatically for the user. +@"auto-updates": AutoUpdates = .off, + /// This is set by the CLI parser for deinit. _arena: ?ArenaAllocator = null, @@ -4096,6 +4103,13 @@ pub const LinuxCgroup = enum { @"single-instance", }; +/// See auto-updates +pub const AutoUpdates = enum { + check, + download, + off, +}; + pub const Duration = struct { /// Duration in nanoseconds duration: u64 = 0,