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

Rhea terminal access #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import time, threading
import os

from nlp import mostSimilar, vectorized_commands
from speechrecog import text_stream, start_listen
from state_track import state, start_state_checking
Expand All @@ -7,6 +9,8 @@
from functions import *
from language_helpers import *

os.system('python preferences.py') #only for mac

KEYWORD = "hey tony"

macros = {}
Expand Down Expand Up @@ -53,4 +57,4 @@ def main():


if __name__ == '__main__':
main()
main()
26 changes: 26 additions & 0 deletions preferences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#only open system preferences if terminal does NOT have control over computer
import os
import sqlite3

#version = os.system("sw_vers -productVersion")

connection = sqlite3.connect("/Library/Application Support/com.apple.TCC/TCC.db")
connection.row_factory = lambda cursor, row: row[0]

cursor = connection.cursor()

try: #first try if big sur (with auth_value in query) will work.
rows = cursor.execute('select client from access where service like "kTCCServiceAccessibility" and auth_value = 2;').fetchall()
if 'com.apple.Terminal' not in rows:
print('Not found')
os.system("open 'x-apple.systempreferences:com.apple.preference.security?Privacy'")
else:
print('Found')

except: #if it errors, assume OS is older. try allowed in query
rows = cursor.execute('select client from access where service like "kTCCServiceAccessibility" and allowed = 1;').fetchall()
if 'com.apple.Terminal' not in rows:
print('Terminal does not have access. Please change this in settings. Opening settings...')
os.system("open 'x-apple.systempreferences:com.apple.preference.security?Privacy'")
else:
print('Found! Terminal has access.')