Skip to content

Commit

Permalink
feat: attempt to update system TCC.db if allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
cmorten committed Dec 9, 2023
1 parent f4bd88f commit bddc5e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 8 additions & 2 deletions src/macOS/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -19,13 +19,19 @@ const isRecorded = process.argv.includes("--record");

export async function setup(): Promise<void> {
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;
Expand Down
5 changes: 3 additions & 2 deletions src/macOS/updateTccDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});`;

Expand Down

0 comments on commit bddc5e8

Please sign in to comment.