mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: start Sparkle after loading config
This commit is contained in:
@ -12,7 +12,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -75,7 +75,7 @@ class AppDelegate: NSObject,
|
|||||||
override init() {
|
override init() {
|
||||||
terminalManager = TerminalManager(ghostty)
|
terminalManager = TerminalManager(ghostty)
|
||||||
updaterController = SPUStandardUpdaterController(
|
updaterController = SPUStandardUpdaterController(
|
||||||
startingUpdater: true,
|
startingUpdater: false,
|
||||||
updaterDelegate: updaterDelegate,
|
updaterDelegate: updaterDelegate,
|
||||||
userDriverDelegate: nil
|
userDriverDelegate: nil
|
||||||
)
|
)
|
||||||
@ -109,11 +109,8 @@ class AppDelegate: NSObject,
|
|||||||
// Initial config loading
|
// Initial config loading
|
||||||
configDidReload(ghostty)
|
configDidReload(ghostty)
|
||||||
|
|
||||||
updaterController.updater.updateCheckInterval = 60
|
// Start our update checker.
|
||||||
updaterController.updater.automaticallyChecksForUpdates =
|
updaterController.startUpdater()
|
||||||
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.
|
// Register our service provider. This must happen after everything is initialized.
|
||||||
NSApp.servicesProvider = ServiceProvider()
|
NSApp.servicesProvider = ServiceProvider()
|
||||||
@ -382,6 +379,12 @@ class AppDelegate: NSObject,
|
|||||||
default: UserDefaults.standard.removeObject(forKey: "NSQuitAlwaysKeepsWindows")
|
default: UserDefaults.standard.removeObject(forKey: "NSQuitAlwaysKeepsWindows")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync our auto-update settings
|
||||||
|
updaterController.updater.automaticallyChecksForUpdates =
|
||||||
|
ghostty.config.autoUpdate == .check || ghostty.config.autoUpdate == .download
|
||||||
|
updaterController.updater.automaticallyDownloadsUpdates =
|
||||||
|
ghostty.config.autoUpdate == .download
|
||||||
|
|
||||||
// Config could change keybindings, so update everything that depends on that
|
// Config could change keybindings, so update everything that depends on that
|
||||||
syncMenuShortcuts()
|
syncMenuShortcuts()
|
||||||
terminalManager.relabelAllTabs()
|
terminalManager.relabelAllTabs()
|
||||||
|
@ -361,15 +361,15 @@ extension Ghostty {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
var autoUpdates: String {
|
var autoUpdate: AutoUpdate {
|
||||||
let defaultValue = "off"
|
let defaultValue = AutoUpdate.check
|
||||||
guard let config = self.config else { return defaultValue }
|
guard let config = self.config else { return defaultValue }
|
||||||
let key = "auto-updates"
|
var v: UnsafePointer<Int8>? = nil
|
||||||
|
let key = "auto-update"
|
||||||
var value: UnsafePointer<Int8>? = nil
|
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
||||||
guard ghostty_config_get(config, &value, key, UInt(key.count)) else { return defaultValue }
|
guard let ptr = v else { return defaultValue }
|
||||||
guard let pointer = value else { return defaultValue }
|
let str = String(cString: ptr)
|
||||||
return String(cString: pointer)
|
return AutoUpdate(rawValue: str) ?? defaultValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,6 +377,12 @@ extension Ghostty {
|
|||||||
// MARK: Configuration Enums
|
// MARK: Configuration Enums
|
||||||
|
|
||||||
extension Ghostty.Config {
|
extension Ghostty.Config {
|
||||||
|
enum AutoUpdate : String {
|
||||||
|
case off
|
||||||
|
case check
|
||||||
|
case download
|
||||||
|
}
|
||||||
|
|
||||||
enum ResizeOverlay : String {
|
enum ResizeOverlay : String {
|
||||||
case always
|
case always
|
||||||
case never
|
case never
|
||||||
|
@ -1462,12 +1462,29 @@ term: []const u8 = "xterm-ghostty",
|
|||||||
/// running. Defaults to an empty string if not set.
|
/// running. Defaults to an empty string if not set.
|
||||||
@"enquiry-response": []const u8 = "",
|
@"enquiry-response": []const u8 = "",
|
||||||
|
|
||||||
/// This controls the automatic update functionality on macOS by setting the
|
/// Control the auto-update functionality of Ghostty. This is only supported
|
||||||
/// properties on the Squirrel automatic update component. By default this is
|
/// on macOS currently, since Linux builds are distributed via package
|
||||||
/// set to "off" which doesn't do anything. The "check" option will automatically
|
/// managers that are not centrally controlled by Ghostty.
|
||||||
/// check for updates but will NOT download them, while as the "download" option
|
///
|
||||||
/// will both check AND download updates automatically for the user.
|
/// Checking or downloading an update does not send any information to
|
||||||
@"auto-updates": AutoUpdates = .off,
|
/// the project beyond standard network information mandated by the
|
||||||
|
/// underlying protocols. To put it another way: Ghostty doesn't explicitly
|
||||||
|
/// add any tracking to the update process. The update process works by
|
||||||
|
/// downloading information about the latest version and comparing it
|
||||||
|
/// client-side to the current version.
|
||||||
|
///
|
||||||
|
/// Valid values are:
|
||||||
|
///
|
||||||
|
/// * `off` - Disable auto-updates.
|
||||||
|
/// * `check` - Check for updates and notify the user if an update is
|
||||||
|
/// available, but do not automatically download or install the update.
|
||||||
|
/// * `download` - Check for updates, automatically download the update,
|
||||||
|
/// notify the user, but do not automatically install the update.
|
||||||
|
///
|
||||||
|
/// The default value is `check`.
|
||||||
|
///
|
||||||
|
/// Changing this value at runtime works after a small delay.
|
||||||
|
@"auto-update": AutoUpdate = .check,
|
||||||
|
|
||||||
/// This is set by the CLI parser for deinit.
|
/// This is set by the CLI parser for deinit.
|
||||||
_arena: ?ArenaAllocator = null,
|
_arena: ?ArenaAllocator = null,
|
||||||
@ -4104,10 +4121,10 @@ pub const LinuxCgroup = enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// See auto-updates
|
/// See auto-updates
|
||||||
pub const AutoUpdates = enum {
|
pub const AutoUpdate = enum {
|
||||||
|
off,
|
||||||
check,
|
check,
|
||||||
download,
|
download,
|
||||||
off,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Duration = struct {
|
pub const Duration = struct {
|
||||||
|
Reference in New Issue
Block a user