# mac-screen-capture-permissions

> Check and request permission to capture the screen

Latest version **2.1.0** (published 2023-09-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install mac-screen-capture-permissions
pnpm add mac-screen-capture-permissions
yarn add mac-screen-capture-permissions
bun add mac-screen-capture-permissions
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2023-09-11 |
| First published | 2019-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 3 |
| Unpacked size | 29.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 119 |
| Author | George Karagkiaouris |
| Maintainers | gkaragkiaouris |
| Keywords | macos, swift, screen, recording, permission, permissions, system, preferences, screen recording, catalina, electron |

## Links

- npm: https://www.npmjs.com/package/mac-screen-capture-permissions
- Repository: https://github.com/karaggeorge/mac-screen-capture-permissions
- Homepage: https://github.com/karaggeorge/mac-screen-capture-permissions#readme
- Issues: https://github.com/karaggeorge/mac-screen-capture-permissions/issues
- npm.io page: https://npm.io/package/mac-screen-capture-permissions

## Dependencies (3)

- [execa](https://npm.io/package/execa.md) ^5.1.1
- [electron-util](https://npm.io/package/electron-util.md) ^0.17.2
- [macos-version](https://npm.io/package/macos-version.md) ^5.2.1

## Recent versions

- 2.1.0 (latest) — 2023-09-11
- 2.0.0 — 2021-04-01
- 1.1.0 — 2019-11-14
- 1.0.3 — 2019-11-12
- 1.0.2 — 2019-11-06
- 1.0.1 — 2019-11-06
- 1.0.0 — 2019-11-06

## README

# 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](https://github.com/karaggeorge/mac-screen-capture-permissions/blob/master/example.js) for usage.

```js
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

---
_Source: https://npm.io/package/mac-screen-capture-permissions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
