Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add screenRecordingPermission option #96

Merged
merged 3 commits into from
Apr 7, 2021

Conversation

wrgoto
Copy link
Contributor

@wrgoto wrgoto commented Jan 28, 2021

Why

One of the significant drawbacks is the library asking for Screen Recording permissions for macOS versions 10.15 and newer. Even though the library doesn't actually record the screen, it is required to get the title of the active window. For those who do not need the window title, there should be an option to forgo the Screen Recording permission check.

Changes

  • Add a disableScreenRecordingPermission option.
  • Skip the screen recording permission check if true.
  • Return an empty string as the title if true.

Related

@sindresorhus
Copy link
Owner

sindresorhus commented Jan 28, 2021

See the feedback in #67. There should be an option for each check.

index.d.ts Outdated

Setting this to true will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property will always be set to an empty string.
*/
disableScreenRecordingPermission: boolean;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disableScreenRecordingPermission: boolean;
screenRecordingPermission: boolean;

index.d.ts Outdated
/**
Disable the screen recording permission check (macOS)

Setting this to true will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property will always be set to an empty string.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should mention the default value with @default.

https://github.com/sindresorhus/typescript-definition-style-guide

readme.md Outdated

## Options

- `disableScreenRecordingPermission` *(boolean)* - Disable the screen recording permission check (macOS). Setting this to true will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property will always be set to an empty string.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readme.md Outdated
@@ -45,13 +45,17 @@ const activeWin = require('active-win');

## API

### activeWin()
### activeWin(options)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### activeWin(options)
### activeWin(options?)

@achuinard
Copy link

@wrgoto Thanks for your contributions!

@wrgoto
Copy link
Contributor Author

wrgoto commented Jan 28, 2021

@sindresorhus I agree there should be an option for each check, but I haven't verified the extent of removing the accessibility check. I'm not entirely sure if it is limited to the url property. I can investigate in a separate issue and PR.

@achuinard
Copy link

@sindresorhus are you looking to get this merged soon?

index.test-d.ts Outdated
@@ -4,7 +4,7 @@ import {Result, LinuxResult, MacOSResult, WindowsResult} from '.';

expectType<Promise<Result | undefined>>(activeWin());

const result = activeWin.sync();
const result = activeWin.sync({ screenRecordingPermission: false });
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const result = activeWin.sync({ screenRecordingPermission: false });
const result = activeWin.sync({screenRecordingPermission: false});

lib/macos.js Outdated

const args = [];
if (options.screenRecordingPermission === false) {
args.push('--disable-screen-recording-permission');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
args.push('--disable-screen-recording-permission');
args.push('--no-screen-recording-permission');

--no is the convention for inverted flags.

readme.md Outdated
Type: `boolean`\
Default: `true`

Enable the screen recording permission check (macOS). Setting this to `false` will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Enable the screen recording permission check (macOS). Setting this to `false` will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string.
Enable the screen recording permission check. Setting this to `false` will prevent the screen recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string.

readme.md Outdated

## Result

Returns a `Promise<Object>` with the result, or `Promise<undefined>` if there is no active window or if the information is not available.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns a `Promise<Object>` with the result, or `Promise<undefined>` if there is no active window or if the information is not available.
Returns a `Promise<object>` with the result, or `Promise<undefined>` if there is no active window or if the information is not available.

readme.md Outdated

Type: `object`

##### screenRecordingPermission
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
##### screenRecordingPermission
##### screenRecordingPermission **(macOS only)**

readme.md Outdated

### activeWin.sync()
#### options
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to document the options twice.

index.d.ts Outdated
@@ -1,4 +1,15 @@
declare namespace activeWin {
interface Options {
/**
Enable the screen recording permission check (macOS).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Enable the screen recording permission check (macOS).
Enable the screen recording permission check. _(macOS)_

index.d.ts Outdated
/**
Enable the screen recording permission check (macOS).

Setting this to `false` will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Setting this to `false` will prevent the Screen Recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string.
Setting this to `false` will prevent the screen recording permission prompt on macOS versions 10.15 and newer. The `title` property in the result will always be set to an empty string.

index.d.ts Outdated

@default true
*/
screenRecordingPermission: boolean;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
screenRecordingPermission: boolean;
readonly screenRecordingPermission: boolean;

@sindresorhus
Copy link
Owner

The PR title needs to be updated.

@wrgoto wrgoto force-pushed the disable-screen-recording branch from e34d0ae to 1d1aa27 Compare April 6, 2021 17:39
@sindresorhus sindresorhus changed the title Add disableScreenRecordingPermission option Add screenRecordingPermission option Apr 7, 2021
@sindresorhus sindresorhus merged commit 9a7bb05 into sindresorhus:main Apr 7, 2021
@wrgoto wrgoto deleted the disable-screen-recording branch April 26, 2021 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants