Repository navigation
Expand file tree
/
Copy pathsetup-access
More file actions
executable file
·54 lines (48 loc) · 2.12 KB
/
Copy pathsetup-access
File metadata and controls
executable file
·54 lines (48 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
"""Interactive, dependency-free macOS permission setup from Terminal."""
import os
from pathlib import Path
import sys
from memo_library import check_access, request_access
def main():
terminal = {
"Apple_Terminal": "Terminal", "iTerm.app": "iTerm", "vscode": "Visual Studio Code",
"WezTerm": "WezTerm", "ghostty": "Ghostty",
}.get(os.environ.get("TERM_PROGRAM"), "the terminal app running this command")
status = request_access()
if status["accessible"]:
print("✓ Voice Memos library is readable. You’re ready to transcribe.")
return 0
if sys.platform != "darwin":
print("Direct Voice Memos library access requires macOS.", file=sys.stderr)
return 3
print("Voice Memos needs a one-time macOS permission setup.\n")
if status.get("settings_opened"):
print("Opened System Settings → Privacy & Security → Full Disk Access.")
else:
print("Could not open System Settings here. Open it manually:")
print(" System Settings → Privacy & Security → Full Disk Access")
print(f"\n1. Enable {terminal} in the list.")
print(" If missing, click + and select that app (Terminal is in Applications/Utilities).")
print("2. Authenticate if macOS asks.")
print("3. Quit and reopen the terminal if macOS requests it, then rerun:")
print(f" {Path(__file__).resolve()}")
print("\nmacOS requires you to grant this permission; this script cannot grant it.")
if not sys.stdin.isatty():
print("Run this command in an interactive Terminal to check again after granting access.")
return 3
while True:
try:
answer = input("\nPress Return to check access again, or q to exit: ").strip()
except (EOFError, KeyboardInterrupt):
print()
return 3
if answer.lower() == "q":
return 3
status = check_access()
if status["accessible"]:
print("✓ Voice Memos library is readable. You’re ready to transcribe.")
return 0
print(status["error"])
if __name__ == "__main__":
sys.exit(main())