Last active
April 17, 2024 21:33
-
-
Save junkblocker/ae66b724e3893f4cde93e188eeac8b26 to your computer and use it in GitHub Desktop.
Disable bunch of #$!@ in Catalina
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| LC_ALL=C | |
| export LC_ALL | |
| me="${0##*/}" | |
| if [ -n "$BASH" ]; then | |
| set -o errexit | |
| set -o nounset | |
| set -o pipefail | |
| fi | |
| IFS=$'\n\t' | |
| # IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it! | |
| signed_out=false | |
| if [[ -z "$(command -v mas)" && -n "$(command -v brew)" ]]; then | |
| brew install mas | |
| fi | |
| if ! mas signout; then | |
| echo "Could not sign out of the apple store automatically." >&2 | |
| else | |
| signed_out=true | |
| fi | |
| if ! $signed_out; then | |
| reply= | |
| while [[ "$reply" != "OK" ]]; do | |
| echo "Please sign out of apple store before proceeding. Type OK when ready or press Ctrl+c to abort." | |
| read -r reply | |
| done | |
| fi | |
| # IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS. | |
| if ! csrutil status | grep -q ' disabled.$'; then | |
| echo "System Integrity Protection is enabled. Can not proceed." >&2 | |
| exit 1 | |
| fi | |
| sudo mount -uw / | |
| # This script needs to be run from the volume you wish to use. | |
| # E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh | |
| full_dir="$(cd "$(dirname $BASH_SOURCE)" && pwd)" | |
| cd "/Volumes/Macintosh HD" | |
| if [[ "${1-}" != "execed" ]]; then | |
| exec "/Volumes/Macintosh HD${full_dir}/${BASH_SOURCE##*/}" execed | |
| fi | |
| disable() { | |
| local what kind | |
| what="$1" | |
| kind="$2" | |
| if [[ -e "./System/Library/Launch${kind}s/${what}.plist" ]]; then | |
| if [[ -e "./System/Library/Launch${kind}s/${what}.plist.org" ]]; then | |
| if ! cmp "./System/Library/Launch${kind}s/${what}.plist" "./System/Library/Launch${kind}s/${what}.plist.org"; then | |
| echo "INFO : Backup ./System/Library/Launch${kind}s/${what}.plist.org" | |
| echo "INFO : Original ./System/Library/Launch${kind}s/${what}.plist" | |
| echo "INFO : are different" | |
| sudo diff -Naup "./System/Library/Launch${kind}s/${what}.plist" "./System/Library/Launch${kind}s/${what}.plist.org" | |
| printf "INFO : Overwrite backup (y/N)? " | |
| reply= | |
| read -r reply | |
| case "$reply" in | |
| y* | Y*) | |
| if ! sudo cp -f "./System/Library/Launch${kind}s/${what}.plist" "./System/Library/Launch${kind}s/${what}.plist.org"; then | |
| echo "FAILURE: Backup failed" >&2 | |
| return | |
| fi | |
| ;; | |
| esac | |
| fi | |
| fi | |
| # Yes, both without and with sudo - See https://www.chromium.org/developers/how-tos/debugging-on-os-x | |
| launchctl unload -wF "./System/Library/Launch${kind}s/${what}.plist" || true | |
| sudo launchctl unload -wF "./System/Library/Launch${kind}s/${what}.plist" || true | |
| if [[ ! -e "./System/Library/Launch${kind}s/${what}.plist.prg" ]]; then | |
| if sudo mv "./System/Library/Launch${kind}s/${what}.plist" "./System/Library/Launch${kind}s/${what}.plist.org"; then | |
| echo "SUCCESS: ${kind} ${what} disabled" | |
| return | |
| fi | |
| echo "FAILURE: ${kind} ${what} could not be disabled" | |
| else | |
| echo "SUCCESS: ${kind} ${what} already disabled" | |
| return | |
| fi | |
| else | |
| if [[ -e "./System/Library/Launch${kind}s/${what}.plist.org" ]]; then | |
| echo "SUCCESS: $kind $what already disabled" | |
| return | |
| else | |
| echo "[??] ${kind} ${what} not present" | |
| fi | |
| fi | |
| } | |
| # WARNING: It might disable things that you may not like. Please double check the services in the TODISABLE vars. | |
| # Get active services: launchctl list | grep -v "\-\t0" | |
| # Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents | |
| # Agents to disable | |
| # 'com.apple.speech.speechdatainstallerd' 'com.apple.speech.speechsynthesisd' 'com.apple.speech.synthesisserver' will freeze Edit menus | |
| # 'com.apple.bird' will prevent saving prompt from being shown | |
| TODISABLE=() | |
| # iCloud | |
| TODISABLE+=('com.apple.security.cloudkeychainproxy3' | |
| 'com.apple.iCloudUserNotifications' | |
| 'com.apple.icloud.findmydeviced.findmydevice-user-agent' | |
| 'com.apple.icloud.fmfd' | |
| 'com.apple.icloud.searchpartyuseragent' | |
| 'com.apple.cloudd' | |
| 'com.apple.cloudpaird' | |
| 'com.apple.cloudphotod' | |
| 'com.apple.followupd' | |
| 'com.apple.protectedcloudstorage.protectedcloudkeysyncing') | |
| # Safari useless stuff | |
| TODISABLE+=('com.apple.SafariBookmarksSyncAgent' | |
| 'com.apple.SafariCloudHistoryPushAgent' | |
| ) | |
| # 'com.apple.WebKit.PluginAgent') | |
| # iMessage / Facetime | |
| TODISABLE+=('com.apple.imagent' | |
| 'com.apple.imautomatichistorydeletionagent' | |
| 'com.apple.imklaunchagent' | |
| 'com.apple.imtransferagent' | |
| 'com.apple.avconferenced') | |
| # Game Center / Passbook / Apple TV / Homekit... | |
| TODISABLE+=('com.apple.gamed' | |
| 'com.apple.passd' | |
| 'com.apple.Maps.pushdaemon' | |
| 'com.apple.videosubscriptionsd' | |
| 'com.apple.CommCenter-osx' | |
| 'com.apple.homed') | |
| # Ad-related | |
| TODISABLE+=('com.apple.ap.adprivacyd' | |
| 'com.apple.ap.adservicesd') | |
| ## Screensharing | |
| #TODISABLE+=('com.apple.screensharing.MessagesAgent' \ | |
| # 'com.apple.screensharing.agent' \ | |
| # 'com.apple.screensharing.menuextra') | |
| # Siri | |
| TODISABLE+=('com.apple.siriknowledged' | |
| 'com.apple.assistant_service' | |
| 'com.apple.assistantd' | |
| 'com.apple.Siri.agent' | |
| 'com.apple.parsec-fbf') | |
| ## VoiceOver / accessibility-related stuff | |
| #TODISABLE+=('com.apple.VoiceOver' \ | |
| # 'com.apple.voicememod' \ | |
| # 'com.apple.accessibility.AXVisualSupportAgent' \ | |
| # 'com.apple.accessibility.dfrhud' \ | |
| # 'com.apple.accessibility.heard') | |
| ## Quicklook | |
| #TODISABLE+=('com.apple.quicklook.ui.helper' \ | |
| # 'com.apple.quicklook.ThumbnailsAgent' \ | |
| # 'com.apple.quicklook') | |
| # Sidecar | |
| TODISABLE+=('com.apple.sidecar-hid-relay' | |
| 'com.apple.sidecar-relay') | |
| # Debugging process | |
| TODISABLE+=('com.apple.spindump_agent' | |
| 'com.apple.ReportCrash' | |
| 'com.apple.ReportGPURestart' | |
| 'com.apple.ReportPanic' | |
| ) | |
| # 'com.apple.DiagnosticReportCleanup' | |
| # 'com.apple.TrustEvaluationAgent') | |
| # Screentime | |
| TODISABLE+=('com.apple.ScreenTimeAgent' | |
| 'com.apple.UsageTrackingAgent') | |
| # Others | |
| TODISABLE+=( | |
| 'com.apple.AirPlayUIAgent' | |
| 'com.apple.AirPortBaseStationAgent' | |
| 'com.apple.familycircled' | |
| 'com.apple.familycontrols.useragent' | |
| 'com.apple.familynotificationd' | |
| 'com.apple.SocialPushAgent' | |
| ) | |
| #TODISABLE+=('com.apple.telephonyutilities.callservicesd' \ | |
| # 'com.apple.photoanalysisd' \ | |
| # 'com.apple.parsecd' \ | |
| # 'com.apple.AOSPushRelay' \ | |
| # 'com.apple.AOSHeartbeat' \ | |
| # 'com.apple.findmymacmessenger' \ | |
| # 'com.apple.sharingd' \ | |
| # 'com.apple.identityservicesd' \ | |
| # 'com.apple.java.InstallOnDemand' \ | |
| # 'com.apple.parentalcontrols.check' \ | |
| # 'com.apple.security.keychain-circle-notification' \ | |
| # 'com.apple.syncdefaultsd' \ | |
| # 'com.apple.appleseed.seedusaged' \ | |
| # 'com.apple.appleseed.seedusaged.postinstall' \ | |
| # 'com.apple.CallHistorySyncHelper' \ | |
| # 'com.apple.RemoteDesktop' \ | |
| # 'com.apple.CallHistoryPluginHelper' \ | |
| # 'com.apple.touristd' \ | |
| # 'com.apple.macos.studentd' \ | |
| # 'com.apple.KeyboardAccessAgent' \ | |
| # 'com.apple.exchange.exchangesyncd' \ | |
| # 'com.apple.suggestd' \ | |
| # 'com.apple.AddressBook.abd' \ | |
| # 'com.apple.helpd' \ | |
| # 'com.apple.amp.mediasharingd' \ | |
| # 'com.apple.mediaanalysisd' \ | |
| # 'com.apple.mediaremoteagent' \ | |
| # 'com.apple.remindd') | |
| for agent in "${TODISABLE[@]}"; do | |
| disable "$agent" Agent | |
| done | |
| # Daemons to disable | |
| TODISABLE=() | |
| ## iCloud | |
| #TODISABLE+=('com.apple.analyticsd') | |
| # | |
| ## Others | |
| TODISABLE+=( | |
| 'com.apple.SubmitDiagInfo' | |
| ) | |
| # 'com.apple.netbiosd' \ | |
| # 'com.apple.preferences.timezone.admintool' \ | |
| # 'com.apple.remotepairtool' \ | |
| # 'com.apple.security.FDERecoveryAgent' \ | |
| # 'com.apple.screensharing' \ | |
| # 'com.apple.appleseed.fbahelperd' \ | |
| # 'com.apple.apsd' \ | |
| # 'com.apple.ManagedClient.cloudconfigurationd' \ | |
| # 'com.apple.ManagedClient.enroll' \ | |
| # 'com.apple.ManagedClient' \ | |
| # 'com.apple.ManagedClient.startup' \ | |
| # 'com.apple.locate' \ | |
| # 'com.apple.locationd' \ | |
| # 'com.apple.eapolcfg_auth' \ | |
| # 'com.apple.RemoteDesktop.PrivilegeProxy' \ | |
| # 'com.apple.mediaremoted') | |
| for daemon in "${TODISABLE[@]}"; do | |
| disable "$daemon" Daemon | |
| done | |
| # vim: set et fdm=manual fenc=utf-8 ff=unix ft=sh ft=sh sts=0 sw=4 ts=4 tw=0 nowrap : |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| LC_ALL=C | |
| export LC_ALL | |
| me="${0##*/}" | |
| if [ -n "$BASH" ]; then | |
| set -o errexit | |
| set -o nounset | |
| set -o pipefail | |
| fi | |
| IFS=$'\n\t' | |
| # IMPORTANT: Don't forget to logout from your Apple ID in the settings before running it! | |
| signed_out=false | |
| if [[ -z "$(command -v mas)" && -n "$(command -v brew)" ]]; then | |
| brew install mas | |
| fi | |
| if ! mas signout; then | |
| echo "Could not sign out of the apple store automatically." >&2 | |
| else | |
| signed_out=true | |
| fi | |
| if ! $signed_out; then | |
| reply= | |
| while [[ "$reply" != "OK" ]]; do | |
| echo "Please sign out of apple store before proceeding. Type OK when ready or press Ctrl+c to abort." | |
| read -r reply | |
| done | |
| fi | |
| # IMPORTANT: You will need to run this script from Recovery. In fact, macOS Catalina brings read-only filesystem which prevent this script from working from the main OS. | |
| if ! csrutil status | grep -q ' disabled.$'; then | |
| echo "System Integrity Protection is enabled. Can not proceed." >&2 | |
| exit 1 | |
| fi | |
| sudo mount -uw / | |
| # This script needs to be run from the volume you wish to use. | |
| # E.g. run it like this: cd /Volumes/Macintosh\ HD && sh /Volumes/Macintosh\ HD/Users/sabri/Desktop/disable.sh | |
| full_dir="$(cd "$(dirname $BASH_SOURCE)" && pwd)" | |
| cd "/Volumes/Macintosh HD" | |
| if [[ "${1-}" != "execed" ]]; then | |
| exec "/Volumes/Macintosh HD${full_dir}/${BASH_SOURCE##*/}" execed | |
| fi | |
| enable() { | |
| local what kind | |
| what="$1" | |
| kind="$2" | |
| if [[ ! -e ./System/Library/Launch${kind}s/${what}.plist ]]; then | |
| if [[ -e ./System/Library/Launch${kind}s/${what}.plist.org ]]; then | |
| if mv "./System/Library/Launch${kind}s/${what}.plist.org" "./System/Library/Launch${kind}s/${what}.plist"; then | |
| echo "SUCCESS: ${kind} ${what} enabled" | |
| launchctl load -w "./System/Library/Launch${kind}s/${what}.plist" || true | |
| sudo launchctl load -w "./System/Library/Launch${kind}s/${what}.plist" || true | |
| return | |
| fi | |
| fi | |
| echo "FAILURE: ${kind} ${what} could not be enabled" | |
| fi | |
| } | |
| # Get active services: launchctl list | grep -v "\-\t0" | |
| # Find a service: grep -lR [service] /System/Library/Launch* /Library/Launch* ~/Library/LaunchAgents | |
| # Agents to enable | |
| TOENABLE=() | |
| # iCloud | |
| TOENABLE+=('com.apple.security.cloudkeychainproxy3' | |
| 'com.apple.iCloudUserNotifications' | |
| 'com.apple.icloud.findmydeviced.findmydevice-user-agent' | |
| 'com.apple.icloud.fmfd' | |
| 'com.apple.icloud.searchpartyuseragent' | |
| 'com.apple.cloudd' | |
| 'com.apple.cloudpaird' | |
| 'com.apple.cloudphotod' | |
| 'com.apple.followupd' | |
| 'com.apple.protectedcloudstorage.protectedcloudkeysyncing') | |
| # Safari useless stuff | |
| TOENABLE+=('com.apple.SafariBookmarksSyncAgent' | |
| 'com.apple.SafariCloudHistoryPushAgent' | |
| 'com.apple.WebKit.PluginAgent') | |
| # iMessage / Facetime | |
| TOENABLE+=('com.apple.imagent' | |
| 'com.apple.imautomatichistorydeletionagent' | |
| 'com.apple.imklaunchagent' | |
| 'com.apple.imtransferagent' | |
| 'com.apple.avconferenced') | |
| # Game Center / Passbook / Apple TV / Homekit... | |
| TOENABLE+=('com.apple.gamed' | |
| 'com.apple.passd' | |
| 'com.apple.Maps.pushdaemon' | |
| 'com.apple.videosubscriptionsd' | |
| 'com.apple.CommCenter-osx' | |
| 'com.apple.homed') | |
| # Ad-related | |
| TOENABLE+=('com.apple.ap.adprivacyd' | |
| 'com.apple.ap.adservicesd') | |
| # Screensharing | |
| TOENABLE+=('com.apple.screensharing.MessagesAgent' | |
| 'com.apple.screensharing.agent' | |
| 'com.apple.screensharing.menuextra') | |
| # Siri | |
| TOENABLE+=('com.apple.siriknowledged' | |
| 'com.apple.assistant_service' | |
| 'com.apple.assistantd' | |
| 'com.apple.Siri.agent' | |
| 'com.apple.parsec-fbf') | |
| # VoiceOver / accessibility-related stuff | |
| TOENABLE+=('com.apple.VoiceOver' | |
| 'com.apple.voicememod' | |
| 'com.apple.accessibility.AXVisualSupportAgent' | |
| 'com.apple.accessibility.dfrhud' | |
| 'com.apple.accessibility.heard') | |
| # Quicklook | |
| TOENABLE+=('com.apple.quicklook.ui.helper' | |
| 'com.apple.quicklook.ThumbnailsAgent' | |
| 'com.apple.quicklook') | |
| # Sidecar | |
| TOENABLE+=('com.apple.sidecar-hid-relay' | |
| 'com.apple.sidecar-relay') | |
| # Debugging process | |
| TOENABLE+=('com.apple.spindump_agent' | |
| 'com.apple.ReportCrash' | |
| 'com.apple.ReportCrash.Root' | |
| 'com.apple.ReportGPURestart' | |
| 'com.apple.ReportPanic' | |
| 'com.apple.DiagnosticReportCleanup' | |
| 'com.apple.TrustEvaluationAgent') | |
| # Screentime | |
| TOENABLE+=('com.apple.ScreenTimeAgent' | |
| 'com.apple.UsageTrackingAgent') | |
| # Others | |
| TOENABLE+=('com.apple.telephonyutilities.callservicesd' | |
| 'com.apple.photoanalysisd' | |
| 'com.apple.parsecd' | |
| 'com.apple.AOSPushRelay' | |
| 'com.apple.AOSHeartbeat' | |
| 'com.apple.AirPlayUIAgent' | |
| 'com.apple.AirPortBaseStationAgent' | |
| 'com.apple.familycircled' | |
| 'com.apple.familycontrols.useragent' | |
| 'com.apple.familynotificationd' | |
| 'com.apple.findmymacmessenger' | |
| 'com.apple.sharingd' | |
| 'com.apple.identityservicesd' | |
| 'com.apple.java.InstallOnDemand' | |
| 'com.apple.parentalcontrols.check' | |
| 'com.apple.security.keychain-circle-notification' | |
| 'com.apple.syncdefaultsd' | |
| 'com.apple.appleseed.seedusaged' | |
| 'com.apple.appleseed.seedusaged.postinstall' | |
| 'com.apple.CallHistorySyncHelper' | |
| 'com.apple.RemoteDesktop' | |
| 'com.apple.CallHistoryPluginHelper' | |
| 'com.apple.SocialPushAgent' | |
| 'com.apple.touristd' | |
| 'com.apple.macos.studentd' | |
| 'com.apple.KeyboardAccessAgent' | |
| 'com.apple.exchange.exchangesyncd' | |
| 'com.apple.suggestd' | |
| 'com.apple.AddressBook.abd' | |
| 'com.apple.helpd' | |
| 'com.apple.amp.mediasharingd' | |
| 'com.apple.mediaanalysisd' | |
| 'com.apple.mediaremoteagent' | |
| 'com.apple.remindd') | |
| for agent in "${TOENABLE[@]}"; do | |
| enable "${agent}" Agent | |
| done | |
| # Daemons to enable | |
| TOENABLE=() | |
| # iCloud | |
| TOENABLE+=('com.apple.analyticsd') | |
| # Others | |
| TOENABLE+=('com.apple.netbiosd' | |
| 'com.apple.preferences.timezone.admintool' | |
| 'com.apple.remotepairtool' | |
| 'com.apple.security.FDERecoveryAgent' | |
| 'com.apple.SubmitDiagInfo' | |
| 'com.apple.screensharing' | |
| 'com.apple.appleseed.fbahelperd' | |
| 'com.apple.apsd' | |
| 'com.apple.ManagedClient.cloudconfigurationd' | |
| 'com.apple.ManagedClient.enroll' | |
| 'com.apple.ManagedClient' | |
| 'com.apple.ManagedClient.startup' | |
| 'com.apple.locate' | |
| 'com.apple.locationd' | |
| 'com.apple.eapolcfg_auth' | |
| 'com.apple.RemoteDesktop.PrivilegeProxy' | |
| 'com.apple.mediaremoted') | |
| for daemon in "${TOENABLE[@]}"; do | |
| enable "${daemon}" Daemon | |
| done | |
| # vim: set et fdm=manual fenc=utf-8 ff=unix ft=sh ft=sh sts=0 sw=4 ts=4 tw=0 nowrap : |
Author
I am not using this script anymore as this whole thing is fraught with system unstability.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What do you think about integrating disable and enable so we only have one script to tweak? This way we can just do
macos_junk_blocker enableto disable crap andmacos_junk_blocker disableto bring things back?Also, what about modularizing the lists so that instead of using
+=each time we just insert a list of the groups that are desired to disable/enable? This might be better done with a config file that has each thing commented in such a fashion: