Browse Source

fix: completely remove hidutil remap that corrupted hardware Option key, restoring native Option hotkey

main
Ali Alavi 2 weeks ago
parent
commit
dfa815bf5e
  1. 10
      src/SonioxSettings.swift

10
src/SonioxSettings.swift

@ -129,7 +129,6 @@ public final class SonioxSettings {
if defaults.object(forKey: "SonioxHotkeyPreset") == nil { if defaults.object(forKey: "SonioxHotkeyPreset") == nil {
defaults.set(HotkeyPreset.option.rawValue, forKey: "SonioxHotkeyPreset") defaults.set(HotkeyPreset.option.rawValue, forKey: "SonioxHotkeyPreset")
} }
ensureHardwareKeyRemapping()
} }
public var language: RecognitionLanguage { public var language: RecognitionLanguage {
@ -261,19 +260,12 @@ public final class SonioxSettings {
defaults.removeObject(forKey: "SonioxLaunchAtLogin") defaults.removeObject(forKey: "SonioxLaunchAtLogin")
defaults.removeObject(forKey: "SonioxPreferredAudioDevice") defaults.removeObject(forKey: "SonioxPreferredAudioDevice")
updateLaunchAtLogin(enabled: false) updateLaunchAtLogin(enabled: false)
ensureHardwareKeyRemapping()
HotkeyManager.shared.registerHotkeys() HotkeyManager.shared.registerHotkeys()
SonioxSessionPool.shared.reconnectAll() SonioxSessionPool.shared.reconnectAll()
} }
public func ensureHardwareKeyRemapping() { 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() { private func installRemappingLaunchAgent() {

Loading…
Cancel
Save