mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 05:50:27 +00:00
macos: add a macos-shortcut config
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import AppKit
|
||||
|
||||
/// Requests permission for Shortcuts app to interact with Ghostty
|
||||
///
|
||||
///
|
||||
/// This function displays a permission dialog asking the user to allow Shortcuts
|
||||
/// to interact with Ghostty. The permission is automatically cached for 10 minutes
|
||||
/// if the user selects "Allow", meaning subsequent intent calls won't show the dialog
|
||||
@@ -25,6 +27,23 @@
|
||||
func requestIntentPermission() async -> Bool {
|
||||
await withCheckedContinuation { continuation in
|
||||
Task { @MainActor in
|
||||
if let delegate = NSApp.delegate as? AppDelegate {
|
||||
switch (delegate.ghostty.config.macosShortcuts) {
|
||||
case .allow:
|
||||
continuation.resume(returning: true)
|
||||
return
|
||||
|
||||
case .deny:
|
||||
continuation.resume(returning: false)
|
||||
return
|
||||
|
||||
case .ask:
|
||||
// Continue with the permission dialog
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PermissionRequest.show(
|
||||
"org.mitchellh.ghostty.shortcutsPermission",
|
||||
message: "Allow Shortcuts to interact with Ghostty for the next 10 minutes?",
|
||||
|
||||
@@ -558,6 +558,17 @@ extension Ghostty {
|
||||
_ = ghostty_config_get(config, &v, key, UInt(key.count))
|
||||
return v
|
||||
}
|
||||
|
||||
var macosShortcuts: MacShortcuts {
|
||||
let defaultValue = MacShortcuts.ask
|
||||
guard let config = self.config else { return defaultValue }
|
||||
var v: UnsafePointer<Int8>? = nil
|
||||
let key = "macos-shortcuts"
|
||||
guard ghostty_config_get(config, &v, key, UInt(key.count)) else { return defaultValue }
|
||||
guard let ptr = v else { return defaultValue }
|
||||
let str = String(cString: ptr)
|
||||
return MacShortcuts(rawValue: str) ?? defaultValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +595,12 @@ extension Ghostty.Config {
|
||||
case always
|
||||
}
|
||||
|
||||
enum MacShortcuts: String {
|
||||
case allow
|
||||
case deny
|
||||
case ask
|
||||
}
|
||||
|
||||
enum ResizeOverlay : String {
|
||||
case always
|
||||
case never
|
||||
|
||||
Reference in New Issue
Block a user