|
|
|
@ -129,7 +129,6 @@ public final class SonioxSettings { |
|
|
|
if defaults.object(forKey: "SonioxHotkeyPreset") == nil { |
|
|
|
defaults.set(HotkeyPreset.option.rawValue, forKey: "SonioxHotkeyPreset") |
|
|
|
} |
|
|
|
ensureHardwareKeyRemapping() |
|
|
|
} |
|
|
|
|
|
|
|
public var language: RecognitionLanguage { |
|
|
|
@ -261,19 +260,12 @@ public final class SonioxSettings { |
|
|
|
defaults.removeObject(forKey: "SonioxLaunchAtLogin") |
|
|
|
defaults.removeObject(forKey: "SonioxPreferredAudioDevice") |
|
|
|
updateLaunchAtLogin(enabled: false) |
|
|
|
ensureHardwareKeyRemapping() |
|
|
|
HotkeyManager.shared.registerHotkeys() |
|
|
|
SonioxSessionPool.shared.reconnectAll() |
|
|
|
} |
|
|
|
|
|
|
|
public func ensureHardwareKeyRemapping() { |
|
|
|
let script = "/usr/bin/hidutil property --set '{\"UserKeyMapping\":[{\"HIDKeyboardModifierMappingSrc\":3221225679,\"HIDKeyboardModifierMappingDst\":1879048254},{\"HIDKeyboardModifierMappingSrc\":4294967451,\"HIDKeyboardModifierMappingDst\":1879048254}]}' >/dev/null 2>&1" |
|
|
|
let task = Process() |
|
|
|
task.executableURL = URL(fileURLWithPath: "/bin/sh") |
|
|
|
task.arguments = ["-c", script] |
|
|
|
try? task.run() |
|
|
|
|
|
|
|
installRemappingLaunchAgent() |
|
|
|
// Disabled: do not mess with system-wide hardware Option key mappings |
|
|
|
} |
|
|
|
|
|
|
|
private func installRemappingLaunchAgent() { |
|
|
|
|