This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathtccplus.applescript
65 lines (51 loc) · 2.27 KB
/
tccplus.applescript
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
55
56
57
58
59
60
61
62
63
64
65
# Applescript Initially created by Will http://junebeetle.github.io/
# Modified by Ben https://github.com/plessbd/
# Uses tccplus https://github.com/jslegendre/tccplus/
to getHomePath()
do shell script "echo ~"
end getHomePath
set strAppPath to POSIX file "/Applications"
set toolPageURL to "https://github.com/jslegendre/tccplus/"
set toolDownloadURL to "https://github.com/jslegendre/tccplus/releases/download/1.0/tccplus.zip"
set supportPath to getHomePath() & "/Library/Application Support/tccplus Wrapper/"
set toolPath to supportPath & "tccplus"
try
do shell script quoted form of toolPath
on error
display dialog "The `tccplus` tool by Jeremy Legendre doesn't seem to be installed." buttons {"Quit", "Visit GitHub", "Download Automatically"} cancel button 1 default button 3
if button returned of result is "Visit GitHub" then
open location toolPageURL
return
end if
do shell script "set -e
mkdir -p " & quoted form of supportPath & "
cd " & quoted form of supportPath & "
curl -fLO " & quoted form of toolDownloadURL & "
unzip tccplus.zip
rm -r __MACOSX
rm tccplus.zip"
display dialog "The tool was downloaded to the following location." default answer toolPath buttons {"OK"} default button 1
end try
set serviceNames to {}
do shell script quoted form of toolPath
repeat with outputLine in paragraphs of result
if outputLine contains " - " then
set serviceNames to serviceNames & (characters 4 thru end of outputLine as string)
end if
end repeat
choose file of type "app" with prompt "Choose an application to add privileges." default location strAppPath
set appPath to POSIX path of result
choose from list serviceNames with prompt "Choose privileges to add." with multiple selections allowed
set services to result
do shell script "defaults read " & quoted form of (appPath & "/Contents/Info.plist") & " CFBundleIdentifier"
set appID to result
set command to ""
repeat with service in services
set command to command & quoted form of toolPath & " add " & service & " " & appID & ";"
end repeat
# set command to quoted form of toolPath & " add " & service & " " & appID
display dialog "The following commands will be run. Is that okay?" buttons {"Cancel", "Run"} default answer command cancel button 1 default button 2
tell application "Terminal"
do script command
activate
end tell