fix: handle new Screen Recording permission on Catalina (closes #29)
This is a light rework of the work from https://github.com/lwouis/alt-tab-macos/pull/33
This commit is contained in:
1 parent
ee85a2f2b2
commit
cbfa5869d9
1 file changed
+11
-1
@@ -31,6 +31,7 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
|
ensureScreenRecordingCheckboxIsChecked()
|
||||||
ensureAccessibilityCheckboxIsChecked()
|
ensureAccessibilityCheckboxIsChecked()
|
||||||
updateThumbnailMaxSize()
|
updateThumbnailMaxSize()
|
||||||
makeStatusBarItem()
|
makeStatusBarItem()
|
||||||
@@ -106,7 +107,16 @@ class Application: NSApplication, NSApplicationDelegate, NSWindowDelegate, NSCol
|
|||||||
|
|
||||||
func ensureAccessibilityCheckboxIsChecked() {
|
func ensureAccessibilityCheckboxIsChecked() {
|
||||||
if !AXIsProcessTrustedWithOptions(["AXTrustedCheckOptionPrompt": true] as CFDictionary) {
|
if !AXIsProcessTrustedWithOptions(["AXTrustedCheckOptionPrompt": true] as CFDictionary) {
|
||||||
debugPrint("The user hasn't checked the accessiblity permission checkbox; please authorize and re-launch\nSee https://help.rescuetime.com/article/59-how-do-i-enable-accessibility-permissions-on-mac-osx")
|
debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Accessibility.\nPlease authorize and re-launch.\nSee https://help.rescuetime.com/article/59-how-do-i-enable-accessibility-permissions-on-mac-osx")
|
||||||
|
NSApp.terminate(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ensureScreenRecordingCheckboxIsChecked() {
|
||||||
|
let firstWindow = cgWindows()[0]
|
||||||
|
let windowImage = CGWindowListCreateImage(.null, .optionIncludingWindow, firstWindow[kCGWindowNumber] as! CGWindowID, [.boundsIgnoreFraming, .bestResolution])
|
||||||
|
if windowImage == nil {
|
||||||
|
debugPrint("Before using this app, you need to give permission in System Preferences > Security & Privacy > Privacy > Screen Recording.\nPlease authorize and re-launch.\nSee https://dropshare.zendesk.com/hc/en-us/articles/360033453434-Enabling-Screen-Recording-Permission-on-macOS-Catalina-10-15-")
|
||||||
NSApp.terminate(self)
|
NSApp.terminate(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user