Skip to content

Commit

Permalink
fix: avoid restarting alt-tab in some rare scenarios (#825)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwouis committed Feb 23, 2021
1 parent 58025af commit 4003df4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/logic/SystemPermissions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@ class SystemPermissions {
}

static func observePermissionsPostStartup() {
var counter = 0
timer = Timer(timeInterval: 5, repeats: true, block: { _ in
if !(accessibilityIsGranted() && screenRecordingIsGranted()) {
if !accessibilityIsGranted() {
App.app.restart()
}
if !screenRecordingIsGranted() {
// permission check may yield a false negative during wake-up
// we restart after 2 negative checks
if counter >= 2 {
App.app.restart()
} else {
counter += 1
}
}
})
timer.tolerance = 4.9
CFRunLoopAddTimer(BackgroundWork.systemPermissionsThread.runLoop, timer, .defaultMode)
Expand Down

0 comments on commit 4003df4

Please sign in to comment.