Skip to content

Commit

Permalink
wulkano#1095 Use different library for screen capture permission
Browse files Browse the repository at this point in the history
  • Loading branch information
thethomasz committed Aug 16, 2022
1 parent 8298b6a commit 4601c0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions main/common/system-permissions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {systemPreferences, shell, dialog, app} from 'electron';
const {hasScreenCapturePermission, hasPromptedForPermission} = require('mac-screen-capture-permissions');
import {getAuthStatus, askForScreenCaptureAccess} from 'node-mac-permissions';
const {ensureDockIsShowing} = require('../utils/dock');

let isDialogShowing = false;
Expand Down Expand Up @@ -73,17 +73,14 @@ const screenCaptureFallback = promptSystemPreferences({
});

export const ensureScreenCapturePermissions = (fallback = screenCaptureFallback) => {
const hadAsked = hasPromptedForPermission();

const hasAccess = hasScreenCapturePermission();

if (hasAccess) {
const status = getAuthStatus('screen');
if (status === 'authorized') {
return true;
}

fallback({hasAsked: !hadAsked});
askForScreenCaptureAccess();
fallback();
return false;
};

export const hasScreenCaptureAccess = () => hasScreenCapturePermission();

export const hasScreenCaptureAccess = () => getAuthStatus('screen') === 'authorized';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"is-online": "^8.4.0",
"lodash": "^4.17.21",
"mac-open-with": "^1.2.3",
"mac-screen-capture-permissions": "^1.1.0",
"mac-windows": "^1.0.0",
"macos-audio-devices": "^1.4.0",
"macos-version": "^5.2.1",
Expand All @@ -69,6 +68,7 @@
"move-file": "^2.0.0",
"nearest-normal-aspect-ratio": "^1.2.1",
"node-mac-app-icon": "^1.4.0",
"node-mac-permissions": "^2.2.1",
"object-hash": "^2.1.1",
"p-cancelable": "^2.1.0",
"p-event": "^4.2.0",
Expand Down

0 comments on commit 4601c0f

Please sign in to comment.