Skip to content

Instantly share code, notes, and snippets.

@reitermarkus
Last active February 6, 2022 14:00
Show Gist options
  • Save reitermarkus/54982e6367508dde7763 to your computer and use it in GitHub Desktop.
Save reitermarkus/54982e6367508dde7763 to your computer and use it in GitHub Desktop.
Scripts to enable Assistive Access programmatically on OS X El Capitan.
#!/usr/bin/python
# Grant Assistive Access to Terminal and “osascript”.
import sqlite3
conn = sqlite3.connect('/Library/Application Support/com.apple.TCC/TCC.db')
conn.cursor().execute("INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','com.apple.Terminal',0,1,1,NULL,NULL)")
conn.cursor().execute("INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','$(which osascript)',1,1,1,NULL,NULL)")
conn.commit()
conn.close()
#!/bin/sh
# Grant Assistive Access to Terminal and “osascript”.
sudo sqlite3 <<EOF
.open '/Library/Application Support/com.apple.TCC/TCC.db'
insert or replace into access values('kTCCServiceAccessibility','com.apple.Terminal',0,1,1,NULL,NULL);
insert or replace into access values('kTCCServiceAccessibility','$(which osascript)',1,1,1,NULL,NULL);
.quit
EOF
@reitermarkus
Copy link
Author

Note the different INSERT commands.
Use 0 when passing a bundle ID (com.apple.Terminal)
and 1 when passing paths to programs (/usr/bin/osascript or $(which osascript)).

@orta
Copy link

orta commented Nov 20, 2016

Looks like Sierra made this not possible

$ sh assistive-access-el-capitan.sh
Password:
Error: near line 2: attempt to write a readonly database
Error: near line 3: attempt to write a readonly database

@rtibdewal
Copy link

Same problem. Did anyone figured a work around?

$ sh assistive-access-el-capitan.sh
Password:
Error: near line 2: attempt to write a readonly database
Error: near line 3: attempt to write a readonly database

@mriddle
Copy link

mriddle commented Jun 20, 2017

Haven't found a workaround. Did find the reason behind it not working though http://applehelpwriter.com/2016/09/20/dropbox-hack-blocked-by-apple-in-sierra/

@rutgerrrrr
Copy link

Would disabling SIP work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment