Skip to content

Commit

Permalink
fix: only perform accessibility check if stdin is tty
Browse files Browse the repository at this point in the history
  • Loading branch information
socsieng committed Dec 31, 2020
1 parent 2c0aa8f commit 6043a78
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions Sources/sendkeys/main.swift
@@ -1,10 +1,16 @@
import SendKeysLib
import Foundation

let accessEnabled = AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String: true] as CFDictionary)
private func isTty() -> Bool {
return isatty(FileHandle.standardInput.fileDescriptor) == 1
}

if isTty() {
let accessEnabled = AXIsProcessTrustedWithOptions([kAXTrustedCheckOptionPrompt.takeUnretainedValue() as String: true] as CFDictionary)

if !accessEnabled {
fputs("\nAccessibility preferences must be enabled to use this tool. If running from the terminal, make sure that your terminal app has accessibility permissiions enabled.\n\n", stderr)
if !accessEnabled {
fputs("\nAccessibility preferences must be enabled to use this tool. If running from the terminal, make sure that your terminal app has accessibility permissiions enabled.\n\n", stderr)
}
}

if #available(OSX 10.11, *) {
Expand Down

0 comments on commit 6043a78

Please sign in to comment.