15

I would like to grant accessibility permission to some apps on Mac using Terminal as per this intruction

https://support.apple.com/en-au/HT202866 which is the accessibility tab in System Preferences

Or this

http://mizage.com/help/accessibility.html

I would like to do that using Terminal so I can setup to install apps (i.e: BetterSnapTool) for many Mac at the same time, given I have admin privilege and this should be applied only on Mavericks and Yosemite

Does anyone know how to do this?

Thanks

8

The accessibility permissions are stored in a sqlite database file at /Library/Application Support/com.apple.TCC/TCC.db.

Since sqlite3 is shipped by default with the later Mac OS X', use it to modify the settings.

The db scheme looks like this:

sqlite> .schema
CREATE TABLE access (service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, allowed INTEGER NOT NULL, prompt_count INTEGER NOT NULL, csreq BLOB, CONSTRAINT key PRIMARY KEY (service, client, client_type));
CREATE TABLE access_overrides (service TEXT PRIMARY KEY NOT NULL);
CREATE TABLE access_times (service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, last_used_time INTEGER NOT NULL, CONSTRAINT key PRIMARY KEY (service, client, client_type));
CREATE TABLE admin (key TEXT PRIMARY KEY NOT NULL, value INTEGER NOT NULL);

The relevant table name is "access" and the relevant field name is "allowed". If allowed contains a "1" the app is granted permission to control the computer, if it contains a "0" the permission is not granted.

With the command

sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'UPDATE access SET allowed = "1";'

you can toggle permission on for all apps listed.

With the command

sudo sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" 'UPDATE access SET allowed = "0";'

you can toggle permission off for all apps listed.

11

klanomath's answer looks good, but if you're like me and aren't as familiar with SQL, want more granular control (enabling/disabling individual apps instead of all at once), or want a clearer interface to work with, you should check out tccutil.py.

Using tccutil, the command you'd want to run to enable an app is

sudo tccutil -e app.bundle.identifier

For example, if you wanted to enable BetterTouchTool, the command you would run is

sudo tccutil -e com.hegenberg.BetterTouchTool

I'm assuming that if you wanted to enable BetterSnapTool the last part would just be com.hegenberg.BetterSnapTool but I don't have that installed on my computer so I can't verify.

You can easily find the correct bundle identifier by running sudo tccutil -l after you've installed the app and it's asked for accessibility permissions (just look for the identifier that maps to the app you want to grant permissions to). If that doesn't quite work (like if the bundle identifier isn't what you expect it to be), you can find it by viewing the app bundle's contents, finding the Info.plist file, and finding the value for the CFBundleIdentifier key.

  • How do we prevent an app from asking all the time? f.e., iTerm2 keeps asking, and I always hit "Deny", but sometime later it will ask again. – trusktr May 24 '18 at 23:29
  • for me, this worked instead: sudo tccutil reset Accessibility – dollar2048 Jan 22 at 22:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .