Coder Social home page Coder Social logo

Comments (8)

sindresorhus avatar sindresorhus commented on May 20, 2024 1

@alex-cory They should be separate methods as they all can't behave exactly the same (some might need to be async, for example).

const {hasPrivacyPermission} = require('electron-util');

console.log(hasPrivacyPermission.fullDiskAccess());
console.log(hasPrivacyPermission.filesAndFoldersDesktop());

from electron-util.

SinghManmohan avatar SinghManmohan commented on May 20, 2024 1

@sindresorhus : Please ignore.. i just tried a sample app and it works.. my bad!

from electron-util.

sindresorhus avatar sindresorhus commented on May 20, 2024

Yeah, could be useful, but there's no "one way" to read the system preferences. What preferences specifically do you need?

from electron-util.

alex-cory avatar alex-cory commented on May 20, 2024

So, I specifically need to display

  1. Accessibility has been enabled for the app (this might work for Accessibility)
  2. Full Disk Access has been enabled for the app
  3. Files and Folders has Documents, Downloads, and Desktop enabled for the app like the Backup and Sync from Google option below
    image

from electron-util.

sindresorhus avatar sindresorhus commented on May 20, 2024

It's not possible to read these from the System Preferences or defaults. It used to be possible to read the database of permissions directly, but this is no longer possible: https://apple.stackexchange.com/questions/362865/macos-list-apps-authorized-for-full-disk-access

Here's how we could do this:

  1. https://github.com/karaggeorge/macos-accessibility-permissions
  2. We can try reading a certain off-limits file: https://github.com/MacPaw/PermissionsKit/blob/43744ea29edb296e177d5890f9fe50d3f5476d52/PermissionsKit/Private/FullDiskAccess/MPFullDiskAccessAuthorizer.m#L68-L76
  3. We can check whether those directories are writable. fs.accessSync(path, fs.constants.W_OK);.

from electron-util.

alex-cory avatar alex-cory commented on May 20, 2024

How do you think this api should look?

readSystemPreferences('Accessibility')
readSystemPreferences('FullDiskAccess')
readSystemPreferences('FilesAndFolders', 'Documents')
readSystemPreferences('FilesAndFolders', 'Downloads')
readSystemPreferences('FilesAndFolders', 'Desktop')

Just throwing ideas out there.

from electron-util.

alex-cory avatar alex-cory commented on May 20, 2024

I can do my best to help implement this.

from electron-util.

SinghManmohan avatar SinghManmohan commented on May 20, 2024

@sindresorhus : Can we open Notifications settings from System Preference directly?

const {openSystemPreferences} = require('electron-util');

openSystemPreferences('notifications');

Screen Shot 2021-02-03 at 2 55 47 PM

from electron-util.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.