Skip to content

Commit 4601c0f

Browse files
committed
#1095 Use different library for screen capture permission
1 parent 8298b6a commit 4601c0f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

main/common/system-permissions.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {systemPreferences, shell, dialog, app} from 'electron';
2-
const {hasScreenCapturePermission, hasPromptedForPermission} = require('mac-screen-capture-permissions');
2+
import {getAuthStatus, askForScreenCaptureAccess} from 'node-mac-permissions';
33
const {ensureDockIsShowing} = require('../utils/dock');
44

55
let isDialogShowing = false;
@@ -73,17 +73,14 @@ const screenCaptureFallback = promptSystemPreferences({
7373
});
7474

7575
export const ensureScreenCapturePermissions = (fallback = screenCaptureFallback) => {
76-
const hadAsked = hasPromptedForPermission();
77-
78-
const hasAccess = hasScreenCapturePermission();
79-
80-
if (hasAccess) {
76+
const status = getAuthStatus('screen');
77+
if (status === 'authorized') {
8178
return true;
8279
}
8380

84-
fallback({hasAsked: !hadAsked});
81+
askForScreenCaptureAccess();
82+
fallback();
8583
return false;
8684
};
8785

88-
export const hasScreenCaptureAccess = () => hasScreenCapturePermission();
89-
86+
export const hasScreenCaptureAccess = () => getAuthStatus('screen') === 'authorized';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"is-online": "^8.4.0",
6161
"lodash": "^4.17.21",
6262
"mac-open-with": "^1.2.3",
63-
"mac-screen-capture-permissions": "^1.1.0",
6463
"mac-windows": "^1.0.0",
6564
"macos-audio-devices": "^1.4.0",
6665
"macos-version": "^5.2.1",
@@ -69,6 +68,7 @@
6968
"move-file": "^2.0.0",
7069
"nearest-normal-aspect-ratio": "^1.2.1",
7170
"node-mac-app-icon": "^1.4.0",
71+
"node-mac-permissions": "^2.2.1",
7272
"object-hash": "^2.1.1",
7373
"p-cancelable": "^2.1.0",
7474
"p-event": "^4.2.0",

0 commit comments

Comments
 (0)