From bddc5e89b9fc439f5c7c7de326c85b031a46f7e3 Mon Sep 17 00:00:00 2001 From: cmorten Date: Sat, 9 Dec 2023 23:24:57 +0000 Subject: [PATCH] feat: attempt to update system TCC.db if allowed --- package.json | 2 +- src/macOS/setup.ts | 10 ++++++++-- src/macOS/updateTccDb.ts | 5 +++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d663c48..11bd18f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@guidepup/setup", - "version": "0.12.1", + "version": "0.13.0", "description": "Setup your environment for screen-reader automation.", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/src/macOS/setup.ts b/src/macOS/setup.ts index 8a669af..ae31d38 100644 --- a/src/macOS/setup.ts +++ b/src/macOS/setup.ts @@ -4,7 +4,7 @@ import { disableSplashScreenSystemDefaults } from "./disableSplashScreenSystemDe import { disableDictationInputAutoEnable } from "./disableDictationInputAutoEnable"; import { isSipEnabled } from "./isSipEnabled"; import { writeDatabaseFile } from "./writeDatabaseFile"; -import { updateTccDb } from "./updateTccDb"; +import { SYSTEM_PATH, USER_PATH, updateTccDb } from "./updateTccDb"; import { isAppleScriptControlEnabled } from "./isAppleScriptControlEnabled"; import { askUserToControlUi } from "./askUserToControlUi"; import { setVoiceOverEnabledViaUi } from "./setVoiceOverEnabledViaUi"; @@ -19,13 +19,19 @@ const isRecorded = process.argv.includes("--record"); export async function setup(): Promise { try { - updateTccDb(); + updateTccDb(USER_PATH); } catch (e) { if (isCi) { throw e; } } + try { + updateTccDb(SYSTEM_PATH); + } catch { + // Swallow error - most CI don't allow system configuration + } + const stopRecording = isRecorded ? record(`./recordings/macos-setup-${+new Date()}.mov`) : () => null; diff --git a/src/macOS/updateTccDb.ts b/src/macOS/updateTccDb.ts index 38ea7ee..0d99bd9 100644 --- a/src/macOS/updateTccDb.ts +++ b/src/macOS/updateTccDb.ts @@ -206,9 +206,10 @@ const getEntries = (): string[] => { ]; }; -const path = "$HOME/Library/Application Support/com.apple.TCC/TCC.db"; +export const USER_PATH = "$HOME/Library/Application Support/com.apple.TCC/TCC.db"; +export const SYSTEM_PATH = "/Library/Application Support/com.apple.TCC/TCC.db"; -export function updateTccDb(): void { +export function updateTccDb(path: string): void { for (const values of getEntries()) { const query = `INSERT OR IGNORE INTO access VALUES(${values});`;