Skip to content

Commit

Permalink
πŸ› Only monitor keybinds when accessibility access is granted
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKai77 committed Aug 10, 2023
1 parent 77fde74 commit 90ba654
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Loop/Helpers/KeybindMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Cocoa

class KeybindMonitor {

static private let accessibilityAccessManager = AccessibilityAccessManager()
static let shared = KeybindMonitor()

private var eventTap: CFMachPort?
Expand Down Expand Up @@ -93,9 +94,11 @@ class KeybindMonitor {

self.eventTap = newEventTap

let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, newEventTap, 0)
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, .commonModes)
CGEvent.tapEnable(tap: newEventTap!, enable: true)
if KeybindMonitor.accessibilityAccessManager.checkAccessibilityAccess() {
let runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, newEventTap, 0)
CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, .commonModes)
CGEvent.tapEnable(tap: newEventTap!, enable: true)
}
}
isEnabled = true
}
Expand Down

0 comments on commit 90ba654

Please sign in to comment.