File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -126,6 +126,12 @@ extension AppDelegate {
126126 showRestartPrompt ( )
127127 stopPermissionMonitoring ( ) // Stop monitoring after showing prompt
128128 }
129+ // Check if permissions were just revoked (changed from true to false)
130+ else if lastPermissionState && !currentPermissionState {
131+ log ( . warning, " Accessibility permissions revoked - immediately deactivating to prevent system crashes " )
132+ stateMachine. deactivate ( )
133+ showPermissionRevokedAlert ( )
134+ }
129135
130136 lastPermissionState = currentPermissionState
131137 }
Original file line number Diff line number Diff line change @@ -39,6 +39,29 @@ func showRestartPrompt() {
3939 }
4040}
4141
42+ func showPermissionRevokedAlert( ) {
43+ let alert = NSAlert ( )
44+ alert. alertStyle = . warning
45+ alert. messageText = " Accessibility permissions revoked "
46+ alert. informativeText = """
47+ Appresize has detected that accessibility permissions were removed.
48+
49+ Window management has been automatically disabled to prevent system instability.
50+
51+ To re-enable window management, please grant accessibility permissions again in System Settings.
52+ """
53+ alert. addButton ( withTitle: " Open System Settings " )
54+ alert. addButton ( withTitle: " OK " )
55+
56+ switch alert. runModal ( ) {
57+ case . alertFirstButtonReturn:
58+ let url = URL ( string: " x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility " ) !
59+ NSWorkspace . shared. open ( url)
60+ default :
61+ break
62+ }
63+ }
64+
4265
4366func restartApp( ) {
4467 let bundlePath = Bundle . main. bundlePath
You can’t perform that action at this time.
0 commit comments