@@ -2,8 +2,8 @@ import Cocoa
2
2
3
3
// macOS has some privacy restrictions. The user needs to grant certain permissions, app by app, in System Preferences > Security & Privacy
4
4
class SystemPermissions {
5
- static var accessibilityIsGranted = PermissionStatus . notGranted
6
- static var screenRecordingIsGranted = PermissionStatus . notGranted
5
+ static var accessibilityPermission = PermissionStatus . notGranted
6
+ static var screenRecordingPermission = PermissionStatus . notGranted
7
7
static var preStartupPermissionsPassed = false
8
8
static var flakyCounter = 0
9
9
static var timerPermissionsToUpdatePermissionsWindow : Timer ?
@@ -44,14 +44,14 @@ class SystemPermissions {
44
44
45
45
@discardableResult
46
46
static func updateAccessibilityIsGranted( ) -> PermissionStatus {
47
- accessibilityIsGranted = detectAccessibilityIsGranted ( )
48
- return accessibilityIsGranted
47
+ accessibilityPermission = detectAccessibilityIsGranted ( )
48
+ return accessibilityPermission
49
49
}
50
50
51
51
@discardableResult
52
52
static func updateScreenRecordingIsGranted( ) -> PermissionStatus {
53
- screenRecordingIsGranted = detectScreenRecordingIsGranted ( )
54
- return screenRecordingIsGranted
53
+ screenRecordingPermission = detectScreenRecordingIsGranted ( )
54
+ return screenRecordingPermission
55
55
}
56
56
57
57
private static func detectAccessibilityIsGranted( ) -> PermissionStatus {
@@ -72,12 +72,12 @@ class SystemPermissions {
72
72
private static func checkPermissionsWhileAltTabIsRunning( ) {
73
73
SystemPermissions . updateAccessibilityIsGranted ( )
74
74
SystemPermissions . updateScreenRecordingIsGranted ( )
75
- Logger . debug ( accessibilityIsGranted , screenRecordingIsGranted , preStartupPermissionsPassed)
76
- Menubar . togglePermissionCallout ( screenRecordingIsGranted == . skipped)
77
- if accessibilityIsGranted == . notGranted {
75
+ Logger . debug ( accessibilityPermission , screenRecordingPermission , preStartupPermissionsPassed)
76
+ Menubar . togglePermissionCallout ( screenRecordingPermission == . skipped)
77
+ if accessibilityPermission == . notGranted {
78
78
App . app. restart ( )
79
79
}
80
- if screenRecordingIsGranted == . notGranted {
80
+ if screenRecordingPermission == . notGranted {
81
81
// permission check may yield a false negative during wake-up
82
82
// we restart after 2 negative checks
83
83
if flakyCounter >= 2 {
@@ -93,22 +93,22 @@ class SystemPermissions {
93
93
private static func checkPermissionsToUpdatePermissionsWindow( _ startupBlock: @escaping ( ) -> Void ) {
94
94
updateAccessibilityIsGranted ( )
95
95
updateScreenRecordingIsGranted ( )
96
- Logger . debug ( accessibilityIsGranted , screenRecordingIsGranted , preStartupPermissionsPassed)
97
- Menubar . togglePermissionCallout ( screenRecordingIsGranted == . skipped)
98
- if accessibilityIsGranted != App . app. permissionsWindow? . accessibilityView? . permissionStatus {
99
- App . app. permissionsWindow? . accessibilityView. updatePermissionStatus ( accessibilityIsGranted )
96
+ Logger . debug ( accessibilityPermission , screenRecordingPermission , preStartupPermissionsPassed)
97
+ Menubar . togglePermissionCallout ( screenRecordingPermission == . skipped)
98
+ if accessibilityPermission != App . app. permissionsWindow? . accessibilityView? . permissionStatus {
99
+ App . app. permissionsWindow? . accessibilityView. updatePermissionStatus ( accessibilityPermission )
100
100
}
101
- if #available( macOS 10 . 15 , * ) , screenRecordingIsGranted != App . app. permissionsWindow? . screenRecordingView? . permissionStatus {
102
- App . app. permissionsWindow? . screenRecordingView? . updatePermissionStatus ( screenRecordingIsGranted )
101
+ if #available( macOS 10 . 15 , * ) , screenRecordingPermission != App . app. permissionsWindow? . screenRecordingView? . permissionStatus {
102
+ App . app. permissionsWindow? . screenRecordingView? . updatePermissionStatus ( screenRecordingPermission )
103
103
}
104
104
if !preStartupPermissionsPassed {
105
- if accessibilityIsGranted != . notGranted && screenRecordingIsGranted != . notGranted {
105
+ if accessibilityPermission != . notGranted && screenRecordingPermission != . notGranted {
106
106
preStartupPermissionsPassed = true
107
107
App . app. permissionsWindow? . close ( )
108
108
startupBlock ( )
109
109
}
110
110
} else {
111
- if accessibilityIsGranted == . notGranted || screenRecordingIsGranted == . notGranted {
111
+ if accessibilityPermission == . notGranted || screenRecordingPermission == . notGranted {
112
112
App . app. restart ( )
113
113
}
114
114
}
0 commit comments