mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Add scaffoling for updating the various settings.
This commit is contained in:
@ -665,8 +665,44 @@ class AppDelegate: NSObject,
|
||||
setSecureInput(.toggle)
|
||||
}
|
||||
|
||||
@IBAction func makeDefaultTerminal(_ sender: Any) {
|
||||
@IBAction func makeGhosttyDefaultTerminal(_ sender: Any) {
|
||||
Ghostty.logger.debug("Clicked makeDefaultTerminal")
|
||||
let ghosttyBundleID = Bundle.main.bundleIdentifier!
|
||||
setDefaultTerminal(bundleID: ghosttyBundleID)
|
||||
}
|
||||
|
||||
@IBAction func makeTerminalDefaultTerminal(_ sender: Any) {
|
||||
Ghostty.logger.debug("Clicked makeTerminalDefaultTerminal")
|
||||
let terminalBundleID = "com.apple.terminal"
|
||||
setDefaultTerminal(bundleID: terminalBundleID)
|
||||
}
|
||||
|
||||
func isGhosttyDefault() -> Bool {
|
||||
return isDefaultTerminal(bundleID: Bundle.main.bundleIdentifier!)
|
||||
}
|
||||
|
||||
func isTerminalDefault() -> Bool {
|
||||
return isDefaultTerminal(bundleID: "com.apple.terminal")
|
||||
}
|
||||
|
||||
func isDefaultTerminal(bundleID: String) -> Bool {
|
||||
return bundleID.isEqual(defaultTerminal())
|
||||
// return CFStringCompare(bundleID as CFString, unixHandler?.takeRetainedValue(), CFStringCompareFlags.compareBackwards) == CFComparisonResult.compareEqualTo
|
||||
}
|
||||
|
||||
func defaultTerminal() -> String {
|
||||
let unixExecutableContentType: CFString = "public.unix-executable" as CFString
|
||||
let unixHandler = LSCopyDefaultRoleHandlerForContentType(unixExecutableContentType, LSRolesMask.shell)
|
||||
let current = unixHandler?.takeRetainedValue() as? String ?? ""
|
||||
|
||||
return current
|
||||
}
|
||||
|
||||
func setDefaultTerminal(bundleID: String) {
|
||||
Ghostty.logger.debug("Setting default terminal to \(bundleID)")
|
||||
Ghostty.logger.debug("Is Ghostty default? \(self.isGhosttyDefault())")
|
||||
Ghostty.logger.debug("Is Terminal default? \(self.isTerminalDefault())")
|
||||
Ghostty.logger.debug("Debugging default terminal: \(self.defaultTerminal())")
|
||||
}
|
||||
|
||||
@IBAction func toggleQuickTerminal(_ sender: Any) {
|
||||
|
@ -86,10 +86,10 @@
|
||||
<action selector="toggleSecureInput:" target="bbz-4X-AYv" id="vWx-z8-5Sy"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Make Default Terminal" id="gFP-FT-8g6">
|
||||
<menuItem title="Make Ghostty Default Terminal" id="gFP-FT-8g6">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeDefaultTerminal:" target="bbz-4X-AYv" id="CaP-G2-Cph"/>
|
||||
<action selector="makeGhosttyDefaultTerminal:" target="bbz-4X-AYv" id="o1U-Dx-VR6"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
|
||||
|
Reference in New Issue
Block a user