-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove_other_apps.sh
executable file
·244 lines (199 loc) · 8.06 KB
/
remove_other_apps.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/bash
# These apps are all system apps protected by SIP
# You will need to disable SIP in Recovery Mode to remove them (not recommended)
# In addition to opening the system up to potential security risks, it will also break some system features
# It's also likely the apps would be reinstalled by the system if you don't disable SIP
remove_app() {
local app_name=$1
local bundle_id=$2
local display_name=$3 # Optional, defaults to app_name
local safety_level=$4 # "safe", "caution", or "system"
if [ -z "$display_name" ]; then
display_name=$app_name
fi
echo "========================================================"
echo "Checking for $display_name and its components..."
# Check for all possible app components
local app_exists=false
local app_path=""
local system_app_path=""
local components_exist=false
local components_list=""
# Check for both locations: /Applications and /System/Applications
if [ -d "/Applications/$app_name.app" ]; then
app_exists=true
components_exist=true
app_path="/Applications/$app_name.app"
components_list+="- Main application (in /Applications)\n"
fi
if [ -d "/System/Applications/$app_name.app" ]; then
app_exists=true
components_exist=true
system_app_path="/System/Applications/$app_name.app"
components_list+="- Main application (in /System/Applications - SIP protected)\n"
fi
# Container files
if [ -d "$HOME/Library/Containers/$bundle_id" ]; then
components_exist=true
components_list+="- Container files\n"
fi
# Caches
if [ -d "$HOME/Library/Caches/$bundle_id" ]; then
components_exist=true
components_list+="- Cache files\n"
fi
# Application support
if [ -d "$HOME/Library/Application Support/$app_name" ]; then
components_exist=true
components_list+="- Application support files\n"
fi
# Preferences
if [ -f "$HOME/Library/Preferences/$bundle_id.plist" ]; then
components_exist=true
components_list+="- Preference files\n"
fi
# If nothing exists, skip
if [ "$components_exist" = false ]; then
echo "No components of $display_name found. Skipping."
echo
return 0
fi
# Report what was found
if [ "$app_exists" = true ]; then
echo "Found $display_name with the following components:"
else
echo "Main app not found, but discovered leftover components:"
fi
echo -e "$components_list"
# Display appropriate warning based on safety level
if [ "$safety_level" = "caution" ]; then
echo "⚠️ CAUTION: Removing this app may affect some system functionality."
echo " It can typically be reinstalled from the App Store if needed."
elif [ "$safety_level" = "system" ]; then
echo "⚠️ WARNING: This is a core system app. Removing it is not recommended."
echo " Removal could impact essential macOS functionality."
echo " Only proceed if you're absolutely certain."
fi
# Special warning for System Applications
if [ -n "$system_app_path" ]; then
echo "⚠️ IMPORTANT: This app is located in /System/Applications."
echo " This directory is protected by System Integrity Protection (SIP)."
echo " You'll need to disable SIP in Recovery Mode to remove this app."
echo " Removing system apps is not recommended without good reason."
echo
echo " To disable SIP (do this only if you're sure):"
echo " 1. Restart and hold Command+R during startup to enter Recovery Mode"
echo " 2. Open Terminal from the Utilities menu"
echo " 3. Run: csrutil disable"
echo " 4. Restart normally and run this script again"
echo " 5. Remember to re-enable SIP afterward with: csrutil enable"
echo
read -p "Skip removal since SIP needs to be disabled first? (Y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Continuing with removal of non-SIP-protected components..."
else
echo "Skipping $display_name removal. Run again after disabling SIP if needed."
echo
return 0
fi
fi
read -p "Remove $display_name components? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping $display_name removal."
echo
return 0
fi
# Double-confirm for system apps
if [ "$safety_level" = "system" ]; then
read -p "Are you REALLY sure you want to remove $display_name? This is a core system app. (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Skipping $display_name removal."
echo
return 0
fi
fi
# Remove the main app
sudo rm -rf "/Applications/$app_name.app"
echo "Removed /Applications/$app_name.app"
# Remove associated container files
if [ -d "$HOME/Library/Containers/$bundle_id" ]; then
rm -rf "$HOME/Library/Containers/$bundle_id"
echo "Removed containers for $display_name"
fi
# Remove caches
if [ -d "$HOME/Library/Caches/$bundle_id" ]; then
rm -rf "$HOME/Library/Caches/$bundle_id"
echo "Removed caches for $display_name"
fi
# Remove application support files
if [ -d "$HOME/Library/Application Support/$app_name" ]; then
rm -rf "$HOME/Library/Application Support/$app_name"
echo "Removed application support files for $display_name"
fi
# Remove preferences
if [ -f "$HOME/Library/Preferences/$bundle_id.plist" ]; then
rm -f "$HOME/Library/Preferences/$bundle_id.plist"
echo "Removed preferences for $display_name"
fi
echo "$display_name has been removed."
echo
}
# Entertainment apps (generally safe to remove)
echo "========================================================"
echo "Entertainment Applications"
echo "These apps can be safely removed without affecting system functionality."
echo
# Chess
remove_app "Chess" "com.apple.Chess" "Chess" "safe"
# Photo Booth
remove_app "Photo Booth" "com.apple.Photo-Booth" "Photo Booth" "safe"
# Stickies
remove_app "Stickies" "com.apple.Stickies" "Stickies" "safe"
# Books
remove_app "Books" "com.apple.Books" "Books" "safe"
# Apple TV
remove_app "TV" "com.apple.TV" "Apple TV" "safe"
# Podcasts
remove_app "Podcasts" "com.apple.podcasts" "Podcasts" "safe"
# Productivity apps (use with some caution)
echo "========================================================"
echo "Productivity & Utility Applications"
echo "These apps can generally be removed, but some macOS features may use them."
echo
# Calculator
remove_app "Calculator" "com.apple.calculator" "Calculator" "safe"
# Voice Memos
remove_app "Voice Memos" "com.apple.VoiceMemos" "Voice Memos" "safe"
# Stock information apps (safe to remove)
echo "========================================================"
echo "Content & Information Applications"
echo "These apps provide content but aren't essential to system functionality."
echo
# News
remove_app "News" "com.apple.news" "Apple News" "safe"
# Stocks
remove_app "Stocks" "com.apple.stocks" "Stocks" "safe"
# Maps
remove_app "Maps" "com.apple.Maps" "Maps" "caution"
# Home automation
remove_app "Home" "com.apple.Home" "Home" "caution"
# Core system apps (not recommended to remove)
echo "========================================================"
echo "Core System Applications"
echo "These apps are more deeply integrated with macOS. Removal is not recommended."
echo "Only proceed if you understand the potential consequences."
echo
# Calendar
remove_app "Calendar" "com.apple.iCal" "Calendar" "system"
# Contacts
remove_app "Contacts" "com.apple.AddressBook" "Contacts" "system"
# FaceTime
remove_app "FaceTime" "com.apple.FaceTime" "FaceTime" "system"
# Find My
remove_app "Find My" "com.apple.findmy" "Find My" "system"
# Reminders
remove_app "Reminders" "com.apple.reminders" "Reminders" "system"
echo "Removal of selected applications complete."