• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    JavaScript
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Check and request permission to capture the screen

mac-screen-capture-permissions

Check and request permission to capture the screen on macOS (introduced with 10.15 Catalina)

Install

Building the module from source requires macOS 11+ SDK, but the resulting module will still run on <10.15, 10.15 and 11+.

$ npm install mac-screen-capture-permissions

Usage

See example.js for usage.

const {
  hasScreenCapturePermission,
  hasPromptedForPermission
} = require('mac-screen-capture-permissions');

hasPromptedForPermission();

// false

hasScreenCapturePermission();

// false

hasPromptedForPermission();

// true


// After accepting the permissions

hasScreenCapturePermission();

// true

API

.hasScreenCapturePermission(): boolean

Whether or not the current app has the required permissions to record the screen. If this is the first time attempting, a permissions dialog will be shown to the user. Any subsequent calls to hasScreenCapturePermission will just check for the permission but won't show a dialog. If the user denied the original request, you need to prompt them to enable the permissions in the System Preferences.

This can be reset by calling resetPermissions. The dialog will be shown again after that.

Returns true on macOS versions older than 10.15 since this permission wasn't present

.hasPromptedForPermission(): boolean

Note: Only works for Electron apps

Whether or not the permission dialog has been shown to the user. Will be false if you haven't called hasScreenCapturePermission for this app yet, and true otherwise.

This can be reset by calling resetPermissions,

Returns false on macOS versions older than 10.15 since this permission wasn't present

.resetPermissions({bundleId?: string}): boolean

Reset the ScreenCapture permissions. It will reset the permissions for all apps, so use with care. Provide a bundleId (i.e. com.apple.Terminal) to reset the permissions only for that app.

Calls tccutil reset ScreenCapture [bundleId].

This will revoke access if it was previously granted, and it will trigger the permissions dialog the next time hasScreenCapturePermission is called.

Returns true if the command executed successfully and false otherwise.

Returns false on macOS versions older than 10.15 since this permission wasn't present

.openSystemPreferences(): Promise<void>

Open the System Preferences in the Screen Recording permissions section under the Security pane.

Only available in Electron apps.

Returns a Promise that resolves when the window is opened

License

MIT

More Repositories

1

macos-key-cast

Log keys pressed on macOS. Useful for screen recordings and presentations.
Swift
255
star
2

macos-audio-devices

Get, set and configure the Audio Devices on macOS
Swift
165
star
3

electron-builder-notarize

Notarize Electron applications using electron-builder
JavaScript
80
star
4

macos-manage-apps

Launch and terminate apps on macOS
Swift
60
star
5

mac-open-with

Open a file with an installed app on macOS
Swift
47
star
6

ink-scrollbar

Scrollbar Component for Ink
JavaScript
40
star
7

kap-recording-time

Show time elapsed while recording
Swift
36
star
8

mac-windows

Provide Information about Application Windows running
Swift
35
star
9

kap-soundflower

Record the system audio using Soundflower
JavaScript
28
star
10

ink-multi-select

Multi select input component for Ink
JavaScript
26
star
11

now-integration

A framework that allows better code structure and routing for ZEIT Integrations
TypeScript
23
star
12

kap-key-cast

Log keys pressed while recording
JavaScript
20
star
13

react-better-password

Password input for ReactJS that mimics mobile password masking behavior
JavaScript
19
star
14

kap-hide-clock

JavaScript
17
star
15

mac-focus-window

Focus a window and bring it to the front on macOS
Swift
15
star
16

kap-playback-speed

Speed up or slow down Kap recordings
JavaScript
14
star
17

kap-camera

JavaScript
14
star
18

macos-accessibility-permissions

Log keys pressed on macOS. Useful for screen recordings and presentations.
JavaScript
10
star
19

hide-desktop-icons

Hide the desktop icons for macOS
Swift
9
star
20

kap-dropbox

Upload recordings to Dropbox
JavaScript
9
star
21

ink-select

Select Component for Ink
JavaScript
7
star
22

kap-recording-name

Create meaningful names for your recordings
JavaScript
5
star
23

ink-aligned

Align Components horizontally for Ink
JavaScript
3
star
24

electron-builder-notarize-pkg

JavaScript
2
star
25

kap-hide-desktop-icons

JavaScript
2
star
26

kap-progress-bar

Add a progress bar to your recordings
JavaScript
2
star
27

now-storyblok

Storyblok integration for ZEIT's Now
TypeScript
2
star
28

kap-do-not-disturb

Silence notifications while recording
JavaScript
2
star
29

now-pusher

Pusher integration for ZEIT's Now
TypeScript
2
star
30

hide-desktop-icons-cli

Clean your desktop by temporarily hiding your icons
JavaScript
2
star
31

test

something
1
star
32

duty-pick-web

A static ReactJS app to utilize the duty-pick API
JavaScript
1
star
33

SpaceShips

A SpaceShip shooting game written in Java using swing and awt
Java
1
star
34

Resume

Resume Website
CSS
1
star
35

kap-reverse

Reverse Kap recordings
JavaScript
1
star
36

crypto-des

Step by step DES algorithm
JavaScript
1
star
37

SmartChecklist

Dynamic checklist that handles and adapts to exceptions
JavaScript
1
star
38

generator-ez-react-component

An easy generator for react components
1
star