mirror of
https://github.com/Lissy93/dotfiles.git
synced 2025-01-23 04:18:34 +01:00
Writes scripts to configure MacOS system preferences
This commit is contained in:
parent
3c4111c2f0
commit
c9d9bcc6db
499
system-specific/macos/system-settings/macos-apps.sh
Executable file
499
system-specific/macos/system-settings/macos-apps.sh
Executable file
@ -0,0 +1,499 @@
|
||||
#!/bin/bash
|
||||
|
||||
##############################################################################
|
||||
# Security improvments for Mac OS systems #
|
||||
# Covers Siri, firewall, account security, connections and network protocols #
|
||||
# #
|
||||
# CAUTION: This script will apply changes to your OS X system configuration #
|
||||
# Be sure to read it through carefully, and remove anything you don't want. #
|
||||
# #
|
||||
# Options: #
|
||||
# --silent - Don't log any status outputs #
|
||||
# --skip-intro - Skip the warning and intro section #
|
||||
# --yes-to-all - Don't ptompt user to agree to changes #
|
||||
# #
|
||||
# Licensed under MIT - (C) Alicia Sykes 2022 <https://aliciasykes.com> #
|
||||
##############################################################################
|
||||
|
||||
############################################################
|
||||
# Initialize variables, check requirements, and print info #
|
||||
############################################################
|
||||
|
||||
# Record start time
|
||||
start_time=`date +%s`
|
||||
|
||||
# Get params
|
||||
params="$params $*"
|
||||
|
||||
# Color variables
|
||||
PRIMARY_COLOR='\033[1;33m'
|
||||
ACCENT_COLOR='\033[0;34m'
|
||||
INFO_COLOR='\033[0;30m'
|
||||
INFO_COLOR_U='\033[4;30m'
|
||||
SUCCESS_COLOR='\033[0;32m'
|
||||
WARN_1='\033[1;31m'
|
||||
WARN_2='\033[0;31m'
|
||||
RESET_COLOR='\033[0m'
|
||||
|
||||
# Current and total taslks, used for progress updates
|
||||
current_event=0
|
||||
total_events=90
|
||||
|
||||
if [ ! "$(uname -s)" = "Darwin" ]; then
|
||||
echo -e "${PRIMARY_COLOR}Incompatible System${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}This script is specific to Mac OS,\
|
||||
and only intended to be run on Darwin-based systems${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! $params == *"--skip-intro"* ]]; then
|
||||
clear
|
||||
|
||||
# Prints intro message
|
||||
echo -e "${PRIMARY_COLOR} MacOS App Preference Script${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}Settings will be applied to the following apps:"
|
||||
echo -e " - Finder"
|
||||
echo -e " - Safari"
|
||||
echo -e " - Mail App"
|
||||
echo -e " - Terminal"
|
||||
echo -e " - Time Machine"
|
||||
echo -e " - Activity Monitor"
|
||||
echo -e " - Mac App Store"
|
||||
echo -e " - Photos App"
|
||||
echo -e " - Messages App"
|
||||
echo -e " - Chromium"
|
||||
echo -e " - Transmission"
|
||||
# Informs user what they're running, and cautions them to read first
|
||||
echo -e "\n${INFO_COLOR}You are running ${0} on\
|
||||
$(hostname -f | sed -e 's/^[^.]*\.//') as $(id -un)${RESET_COLOR}"
|
||||
echo -e "${WARN_1}IMPORTANT:${WARN_2} This script will make changes to your system."
|
||||
echo -e "${WARN_2}Ensure that you've read it through before continuing.${RESET_COLOR}"
|
||||
|
||||
# Ask for user confirmation before proceeding (if skip flag isn't passed)
|
||||
if [[ ! $params == *"--yes-to-all"* ]]; then
|
||||
echo -e "\n${PRIMARY_COLOR}Would you like to proceed? (y/N)${RESET_COLOR}"
|
||||
read -t 15 -n 1 -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo -e "${ACCENT_COLOR}\nNo worries, nothing will be applied - feel free to come back another time."
|
||||
echo -e "${PRIMARY_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Check have got admin privilages
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${ACCENT_COLOR}\nElevated permissions are required to adjust system settings."
|
||||
echo -e "${PRIMARY_COLOR}Please enter your password...${RESET_COLOR}"
|
||||
script_path=$([[ "$0" = /* ]] && echo "$0" || echo "$PWD/${0#./}")
|
||||
params="--skip-intro ${params}"
|
||||
sudo "$script_path" $params || (
|
||||
echo -e "${ACCENT_COLOR}Unable to continue without sudo permissions"
|
||||
echo -e "${PRIMARY_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 1
|
||||
)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Helper function to log progress to console
|
||||
function log_msg () {
|
||||
current_event=$(($current_event + 1))
|
||||
if [[ ! $params == *"--silent"* ]]; then
|
||||
if (("$current_event" < 10 )); then sp='0'; else sp=''; fi
|
||||
echo -e "${PRIMARY_COLOR}[${sp}${current_event}/${total_events}] ${ACCENT_COLOR}${1}${INFO_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper function to log section to console
|
||||
function log_section () {
|
||||
if [[ ! $params == *"--silent"* ]]; then
|
||||
echo -e "${PRIMARY_COLOR}[INFO ] ${1}${INFO_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "\n${PRIMARY_COLOR}Starting...${RESET_COLOR}"
|
||||
|
||||
|
||||
|
||||
##########
|
||||
# Finder #
|
||||
##########
|
||||
log_section "Finder"
|
||||
|
||||
log_msg "Open new tabs to Home"
|
||||
defaults write com.apple.finder NewWindowTarget -string "PfHm"
|
||||
|
||||
log_msg "Open new windows to file root"
|
||||
defaults write com.apple.finder NewWindowTargetPath -string "file:///"
|
||||
|
||||
log_msg "Show hidden files"
|
||||
defaults write com.apple.finder AppleShowAllFiles -bool true
|
||||
|
||||
log_msg "Show file extensions"
|
||||
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
|
||||
|
||||
log_msg "Don't ask before emptying trash"
|
||||
defaults write com.apple.finder WarnOnEmptyTrash -bool false
|
||||
|
||||
log_msg "View all network locations"
|
||||
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
|
||||
|
||||
log_msg "Show the ~/Library folder"
|
||||
chflags nohidden ~/Library && xattr -d com.apple.FinderInfo ~/Library
|
||||
|
||||
log_msg "Show the /Volumes folder"
|
||||
sudo chflags nohidden /Volumes
|
||||
|
||||
log_msg "Allow finder to be fully quitted with ⌘ + Q"
|
||||
defaults write com.apple.finder QuitMenuItem -bool true
|
||||
|
||||
log_msg "Show the status bar in Finder"
|
||||
defaults write com.apple.finder ShowStatusBar -bool true
|
||||
|
||||
log_msg "Show the path bar in finder"
|
||||
defaults write com.apple.finder ShowPathbar -bool true
|
||||
|
||||
log_msg "Display full POSIX path as Finder window title"
|
||||
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
|
||||
|
||||
log_msg "Expand the General, Open and Privlages file info panes"
|
||||
defaults write com.apple.finder FXInfoPanesExpanded -dict \
|
||||
General -bool true \
|
||||
OpenWith -bool true \
|
||||
Privileges -bool true
|
||||
|
||||
|
||||
log_msg "Keep directories at top of search results"
|
||||
defaults write com.apple.finder _FXSortFoldersFirst -bool true
|
||||
|
||||
log_msg "Search current directory by default"
|
||||
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
|
||||
|
||||
log_msg "Don't show warning when changing extension"
|
||||
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
|
||||
|
||||
log_msg "Don't add .DS_Store to network drives"
|
||||
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
|
||||
|
||||
log_msg "Don't add .DS_Store to USB devices"
|
||||
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
|
||||
|
||||
log_msg "Disable disk image verification"
|
||||
defaults write com.apple.frameworks.diskimages skip-verify -bool true
|
||||
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
|
||||
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
|
||||
|
||||
log_msg "Open a new Finder window when a volume is mounted"
|
||||
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
|
||||
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
|
||||
|
||||
log_msg "Open a new Finder window when a disk is mounted"
|
||||
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
|
||||
|
||||
log_msg "Show item info"
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
log_msg "Enable snap-to-grid for icons on the desktop and finder"
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
log_msg "Set grid spacing for icons on the desktop and finder"
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
log_msg "Set icon size on desktop and in finder"
|
||||
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
|
||||
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 80" ~/Library/Preferences/com.apple.finder.plist
|
||||
|
||||
|
||||
|
||||
########################################
|
||||
# Safari & Webkit Privacy Enchanements #
|
||||
########################################
|
||||
log_section "Safari and Webkit"
|
||||
|
||||
log_msg "Don't send search history to Apple"
|
||||
defaults write com.apple.Safari UniversalSearchEnabled -bool false
|
||||
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
|
||||
|
||||
log_msg "Allow using tab to highlight elements"
|
||||
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
|
||||
|
||||
log_msg "Show full URL"
|
||||
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
|
||||
|
||||
log_msg "Set homepage"
|
||||
defaults write com.apple.Safari HomePage -string "about:blank"
|
||||
|
||||
log_msg "Don't open downloaded files automatically"
|
||||
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
|
||||
|
||||
log_msg "Hide favorites bar"
|
||||
defaults write com.apple.Safari ShowFavoritesBar -bool false
|
||||
|
||||
log_msg "Hide sidebar"
|
||||
defaults write com.apple.Safari ShowSidebarInTopSites -bool false
|
||||
|
||||
log_msg "Disable thumbnail cache"
|
||||
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
|
||||
|
||||
log_msg "Enable debug menu"
|
||||
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
|
||||
|
||||
log_msg "Search feature matches any part of word"
|
||||
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
|
||||
|
||||
log_msg "Remove unneeded icons from bookmarks bar"
|
||||
defaults write com.apple.Safari ProxiesInBookmarksBar "()"
|
||||
|
||||
log_msg "Enable developer options"
|
||||
defaults write com.apple.Safari IncludeDevelopMenu -bool true
|
||||
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
|
||||
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
|
||||
|
||||
log_msg "Enable spell check"
|
||||
defaults write com.apple.Safari WebContinuousSpellCheckingEnabled -bool true
|
||||
|
||||
log_msg "Disable auto-correct"
|
||||
defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false
|
||||
|
||||
log_msg "Disable auto-fill addressess"
|
||||
defaults write com.apple.Safari AutoFillFromAddressBook -bool false
|
||||
|
||||
log_msg "Disable auto-fill passwords"
|
||||
defaults write com.apple.Safari AutoFillPasswords -bool false
|
||||
|
||||
log_msg "Disable auto-fill credit cards"
|
||||
defaults write com.apple.Safari AutoFillCreditCardData -bool false
|
||||
|
||||
log_msg "Disable auto-fill misc forms"
|
||||
defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false
|
||||
|
||||
log_msg "Enable fraud warnings"
|
||||
defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool true
|
||||
|
||||
log_msg "Disable web plugins"
|
||||
defaults write com.apple.Safari WebKitPluginsEnabled -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2PluginsEnabled -bool false
|
||||
|
||||
log_msg "Disable Java"
|
||||
defaults write com.apple.Safari WebKitJavaEnabled -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabled -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaEnabledForLocalFiles -bool false
|
||||
|
||||
log_msg "Prevent pop-ups"
|
||||
defaults write com.apple.Safari WebKitJavaScriptCanOpenWindowsAutomatically -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2JavaScriptCanOpenWindowsAutomatically -bool false
|
||||
|
||||
log_msg "Dissallow auto-play"
|
||||
defaults write com.apple.Safari WebKitMediaPlaybackAllowsInline -bool false
|
||||
defaults write com.apple.SafariTechnologyPreview WebKitMediaPlaybackAllowsInline -bool false
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
|
||||
defaults write com.apple.SafariTechnologyPreview com.apple.Safari.ContentPageGroupIdentifier.WebKit2AllowsInlineMediaPlayback -bool false
|
||||
|
||||
log_msg "Use Do not Track header"
|
||||
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true
|
||||
|
||||
log_msg "Auto-update Extensions"
|
||||
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true
|
||||
|
||||
##################
|
||||
# Apple Mail App #
|
||||
##################
|
||||
log_section "Apple Mail App"
|
||||
|
||||
log_msg "Copy only email address, not name"
|
||||
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
|
||||
|
||||
log_msg "Use ⌘ + Enter shortcut to quick send emails"
|
||||
defaults write com.apple.mail NSUserKeyEquivalents -dict-add "Send" "@\U21a9"
|
||||
|
||||
log_msg "Display messages in thread mode"
|
||||
defaults write com.apple.mail DraftsViewerAttributes -dict-add "DisplayInThreadedMode" -string "yes"
|
||||
|
||||
log_msg "Sort messages by date"
|
||||
defaults write com.apple.mail DraftsViewerAttributes -dict-add "SortOrder" -string "received-date"
|
||||
|
||||
log_msg "Sort by newest to oldest"
|
||||
defaults write com.apple.mail DraftsViewerAttributes -dict-add "SortedDescending" -string "yes"
|
||||
|
||||
log_msg "Disable inline attatchment viewing"
|
||||
defaults write com.apple.mail DisableInlineAttachmentViewing -bool true
|
||||
|
||||
################
|
||||
# Terminal App #
|
||||
################
|
||||
log_section "Terminal App"
|
||||
|
||||
log_msg "Set Terminal to only use UTF-8"
|
||||
defaults write com.apple.terminal StringEncodings -array 4
|
||||
|
||||
log_msg "Enable secure entry for Terminal"
|
||||
defaults write com.apple.terminal SecureKeyboardEntry -bool true
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Time Machine #
|
||||
###############################################################################
|
||||
log_section "Time Machine"
|
||||
|
||||
log_msg "Prevent Time Machine prompting to use new drive as backup"
|
||||
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
|
||||
|
||||
log_msg "Disable local Time Machine backups"
|
||||
hash tmutil &> /dev/null && sudo tmutil disablelocal
|
||||
|
||||
###############################################################################
|
||||
# Activity Monitor #
|
||||
###############################################################################
|
||||
log_section "Activity Monitor"
|
||||
|
||||
log_msg "Show the main window when launching Activity Monitor"
|
||||
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true
|
||||
|
||||
log_msg "Visualize CPU usage in the Activity Monitor Dock icon"
|
||||
defaults write com.apple.ActivityMonitor IconType -int 5
|
||||
|
||||
log_msg "Show all processes in Activity Monitor"
|
||||
defaults write com.apple.ActivityMonitor ShowCategory -int 0
|
||||
|
||||
log_msg "Sort results by CPU usage"
|
||||
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
|
||||
defaults write com.apple.ActivityMonitor SortDirection -int 0
|
||||
|
||||
###################
|
||||
# Apple Mac Store #
|
||||
###################
|
||||
log_section "Apple Mac Store"
|
||||
|
||||
log_msg "Allow automatic update checks"
|
||||
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true
|
||||
|
||||
log_msg "Auto install criticial security updates"
|
||||
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
|
||||
|
||||
log_msg "Enable the debug menu"
|
||||
defaults write com.apple.appstore ShowDebugMenu -bool true
|
||||
|
||||
log_msg "Enable extra dev tools"
|
||||
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
|
||||
|
||||
####################
|
||||
# Apple Photos App #
|
||||
####################
|
||||
log_section "Apple Photos App"
|
||||
|
||||
log_msg "Prevent Photos from opening automatically when devices are plugged in"
|
||||
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
|
||||
|
||||
######################
|
||||
# Apple Messages App #
|
||||
######################
|
||||
log_section "Apple Messages App"
|
||||
|
||||
log_msg "Disable automatic emoji substitution"
|
||||
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
|
||||
|
||||
log_msg "Disable smart quotes"
|
||||
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
|
||||
|
||||
#############################################################
|
||||
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility #
|
||||
#############################################################
|
||||
log_section "Address Book, Calendar, TextEdit"
|
||||
|
||||
log_msg "Enable the debug menu in Address Book"
|
||||
defaults write com.apple.addressbook ABShowDebugMenu -bool true
|
||||
|
||||
log_msg "Enable Dashboard dev mode"
|
||||
defaults write com.apple.dashboard devmode -bool true
|
||||
|
||||
log_msg "Use plaintext for new text documents"
|
||||
defaults write com.apple.TextEdit RichText -int 0
|
||||
|
||||
log_msg "Use UTF-8 for opening text files"
|
||||
defaults write com.apple.TextEdit PlainTextEncoding -int 4
|
||||
|
||||
log_msg "Use UTF-8 for saving text files"
|
||||
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
|
||||
|
||||
log_msg "Enable the debug menu in Disk Utility"
|
||||
defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true
|
||||
defaults write com.apple.DiskUtility advanced-image-options -bool true
|
||||
|
||||
log_msg "Auto-play videos when opened with QuickTime Player"
|
||||
defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen -bool true
|
||||
|
||||
########################################
|
||||
# Google Chrome & Google Chrome Canary #
|
||||
########################################
|
||||
log_section "Chromium"
|
||||
|
||||
log_msg "Use the system-native print preview dialog"
|
||||
defaults write com.google.Chrome DisablePrintPreview -bool true
|
||||
defaults write com.google.Chrome.canary DisablePrintPreview -bool true
|
||||
|
||||
log_msg "Expand the print dialog by default"
|
||||
defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true
|
||||
defaults write com.google.Chrome.canary PMPrintingExpandedStateForPrint2 -bool true
|
||||
|
||||
####################
|
||||
# Transmission.app #
|
||||
####################
|
||||
log_section "Transmission"
|
||||
|
||||
log_msg "Store incomplete downloads in the Downloads/torrents dir"
|
||||
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
|
||||
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Documents/Torrents"
|
||||
|
||||
log_msg "Store completed downloads in Downloads directory"
|
||||
defaults write org.m0k.transmission DownloadLocationConstant -bool true
|
||||
|
||||
log_msg "Dont prompt for confirmation before downloading"
|
||||
defaults write org.m0k.transmission DownloadAsk -bool false
|
||||
defaults write org.m0k.transmission MagnetOpenAsk -bool false
|
||||
|
||||
log_msg "No confirmation before removing non-downloading transfers"
|
||||
defaults write org.m0k.transmission CheckRemoveDownloading -bool true
|
||||
|
||||
log_msg "Trash original torrents"
|
||||
defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
|
||||
|
||||
log_msg "Hide the donate message"
|
||||
defaults write org.m0k.transmission WarningDonate -bool false
|
||||
|
||||
log_msg "Hide the legal disclaimer"
|
||||
defaults write org.m0k.transmission WarningLegal -bool false
|
||||
|
||||
log_msg "Set IP blocklists"
|
||||
defaults write org.m0k.transmission BlocklistNew -bool true
|
||||
defaults write org.m0k.transmission BlocklistURL -string "http://john.bitsurge.net/public/biglist.p2p.gz"
|
||||
defaults write org.m0k.transmission BlocklistAutoUpdate -bool true
|
||||
|
||||
log_msg "Randomize port on launch"
|
||||
defaults write org.m0k.transmission RandomPort -bool true
|
||||
|
||||
#####################################
|
||||
# Print finishing message, and exit #
|
||||
#####################################
|
||||
echo -e "${PRIMARY_COLOR}\nFinishing...${RESET_COLOR}"
|
||||
echo -e "${SUCCESS_COLOR}✔ ${current_event}/${total_events} tasks were completed \
|
||||
succesfully in $((`date +%s`-start_time)) seconds${RESET_COLOR}"
|
||||
echo -e "\n${PRIMARY_COLOR} .:'\n __ :'__\n .'\`__\`-'__\`\`.\n \
|
||||
:__________.-'\n :_________:\n :_________\`-;\n \`.__.-.__.'\n${RESET_COLOR}"
|
||||
|
||||
if [[ ! $params == *"--quick-exit"* ]]; then
|
||||
echo -e "${ACCENT_COLOR}Press any key to continue.${RESET_COLOR}"
|
||||
read -t 5 -n 1 -s
|
||||
fi
|
||||
exit 0
|
463
system-specific/macos/system-settings/macos-preferences.sh
Executable file
463
system-specific/macos/system-settings/macos-preferences.sh
Executable file
@ -0,0 +1,463 @@
|
||||
#!/bin/bash
|
||||
|
||||
##############################################################################
|
||||
# Applies MacOS settings and preferences in /Library/Preferences #
|
||||
# Covers Spotlight, layout, colors, fonts, mouse, keyboard and shortcuts #
|
||||
# #
|
||||
# CAUTION: This script will apply changes to your OS X system configuration #
|
||||
# Be sure to read it through carefully, and remove anything you don't want. #
|
||||
# #
|
||||
# Options: #
|
||||
# --silent - Don't log any status outputs #
|
||||
# --skip-intro - Skip the warning and intro section #
|
||||
# --yes-to-all - Don't ptompt user to agree to changes #
|
||||
# #
|
||||
# Licensed under MIT - (C) Alicia Sykes 2022 <https://aliciasykes.com> #
|
||||
##############################################################################
|
||||
|
||||
############################################################
|
||||
# Initialize variables, check requirements, and print info #
|
||||
############################################################
|
||||
|
||||
# Record start time
|
||||
start_time=`date +%s`
|
||||
|
||||
# Get params
|
||||
params="$params $*"
|
||||
|
||||
# Color variables
|
||||
PRIMARY_COLOR='\033[1;33m'
|
||||
ACCENT_COLOR='\033[0;34m'
|
||||
INFO_COLOR='\033[0;30m'
|
||||
INFO_COLOR_U='\033[4;30m'
|
||||
SUCCESS_COLOR='\033[0;32m'
|
||||
WARN_1='\033[1;31m'
|
||||
WARN_2='\033[0;31m'
|
||||
RESET_COLOR='\033[0m'
|
||||
|
||||
# Current and total taslks, used for progress updates
|
||||
current_event=0
|
||||
total_events=68
|
||||
|
||||
# Check system is compatible
|
||||
if [ ! "$(uname -s)" = "Darwin" ]; then
|
||||
echo -e "${PRIMARY_COLOR}Incompatible System${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}This script is specific to Mac OS,\
|
||||
and only intended to be run on Darwin-based systems${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Print info, and prompt for confrimation
|
||||
if [[ ! $params == *"--skip-intro"* ]]; then
|
||||
# Output what stuff will be updated
|
||||
echo -e "${PRIMARY_COLOR} MacOS User Preferences${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}The following sections will be executed:"
|
||||
echo -e " - Device info"
|
||||
echo -e " - Localization"
|
||||
echo -e " - UI Settings"
|
||||
echo -e " - Opening, saving and printing files"
|
||||
echo -e " - System power and lock screen options"
|
||||
echo -e " - Sound and display quality"
|
||||
echo -e " - Keyboard and input"
|
||||
echo -e " - Mouse and trackpad"
|
||||
echo -e " - Spotlight and search"
|
||||
echo -e " - Dock and Launchpad"
|
||||
|
||||
# Inform user what they're running, and cautions them to read first
|
||||
echo -e "\n${INFO_COLOR}You are running ${0} on\
|
||||
$(hostname -f | sed -e 's/^[^.]*\.//') as $(id -un)${RESET_COLOR}"
|
||||
echo -e "${WARN_1}IMPORTANT:${WARN_2} This script will make changes to your system.\
|
||||
Ensure you've read it through before continuing${RESET_COLOR}"
|
||||
|
||||
# Ask for user confirmation before proceeding (if skip flag isn't passed)
|
||||
if [[ ! $params == *"--yes-to-all"* ]]; then
|
||||
echo -e "\n${PRIMARY_COLOR}Would you like to proceed? (y/N)${RESET_COLOR}"
|
||||
read -t 15 -n 1 -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo -e "${ACCENT_COLOR}\nNo worries, nothing will be applied - feel free to come back another time."
|
||||
echo -e "${PRIMARY_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check have got admin privilages
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${ACCENT_COLOR}\nElevated permissions are required to adjust system settings."
|
||||
echo -e "${PRIMARY_COLOR}Please enter your password...${RESET_COLOR}"
|
||||
script_path=$([[ "$0" = /* ]] && echo "$0" || echo "$PWD/${0#./}")
|
||||
params="--skip-intro ${params}"
|
||||
sudo "$script_path" $params || (
|
||||
echo -e "${ACCENT_COLOR}Unable to continue without sudo permissions"
|
||||
echo -e "${PRIMARY_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 1
|
||||
)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Helper function to log progress to console
|
||||
function log_msg () {
|
||||
current_event=$(($current_event + 1))
|
||||
if [[ ! $params == *"--silent"* ]]; then
|
||||
if (("$current_event" < 10 )); then sp='0'; else sp=''; fi
|
||||
echo -e "${PRIMARY_COLOR}[${sp}${current_event}/${total_events}] ${ACCENT_COLOR}${1}${INFO_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper function to log section to console
|
||||
function log_section () {
|
||||
if [[ ! $params == *"--silent"* ]]; then
|
||||
echo -e "${PRIMARY_COLOR}[INFO ] ${1}${INFO_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "\n${PRIMARY_COLOR}Starting...${RESET_COLOR}"
|
||||
|
||||
# Vzariables for system preferences
|
||||
COMPUTER_NAME="AS-AND-MacBook"
|
||||
HIGHLIGHT_COLOR="0 0.8 0.7"
|
||||
|
||||
# Quit System Preferences before starting
|
||||
osascript -e 'tell application "System Preferences" to quit'
|
||||
|
||||
###################
|
||||
# Set Device Info #
|
||||
###################
|
||||
log_section "Device Info"
|
||||
|
||||
# Set computer name and hostname
|
||||
log_msg "Set computer name"
|
||||
sudo scutil --set ComputerName "$COMPUTER_NAME"
|
||||
|
||||
log_msg "Set remote hostname"
|
||||
sudo scutil --set HostName "$COMPUTER_NAME"
|
||||
|
||||
log_msg "Set local hostname"
|
||||
sudo scutil --set LocalHostName "$COMPUTER_NAME"
|
||||
|
||||
log_msg "Set SMB hostname"
|
||||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$COMPUTER_NAME"
|
||||
|
||||
############################
|
||||
# Location and locale info #
|
||||
############################
|
||||
log_section "Local Preferences"
|
||||
|
||||
log_msg "Set language to English"
|
||||
defaults write NSGlobalDomain AppleLanguages -array "en"
|
||||
|
||||
log_msg "Set locale to British"
|
||||
defaults write NSGlobalDomain AppleLocale -string "en_GB@currency=GBP"
|
||||
|
||||
log_msg "Set time zone to London"
|
||||
sudo systemsetup -settimezone "Europe/London" > /dev/null
|
||||
|
||||
log_msg "Set units to metric"
|
||||
defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
|
||||
defaults write NSGlobalDomain AppleMetricUnits -bool true
|
||||
|
||||
###############
|
||||
# UI Settings #
|
||||
###############
|
||||
log_section "UI Settings"
|
||||
|
||||
# Set highlight color
|
||||
log_msg "Set text highlight color"
|
||||
defaults write NSGlobalDomain AppleHighlightColor -string "${HIGHLIGHT_COLOR}"
|
||||
|
||||
##################
|
||||
# File Locations #
|
||||
##################
|
||||
log_section "File Locations"
|
||||
|
||||
log_msg "Set location to save screenshots to"
|
||||
defaults write com.apple.screencapture location -string "${HOME}/Downloads/screenshots"
|
||||
|
||||
log_msg "Save screenshots in .png format"
|
||||
defaults write com.apple.screencapture type -string "png"
|
||||
|
||||
###############################################
|
||||
# Saving, Opening, Printing and Viewing Files #
|
||||
###############################################
|
||||
log_section "Opening, Saving and Printing Files"
|
||||
|
||||
log_msg "Set scrollbar to always show"
|
||||
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
|
||||
|
||||
log_msg "Set sidebar icon size to medium"
|
||||
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
|
||||
|
||||
log_msg "Set toolbar title rollover delay"
|
||||
defaults write NSGlobalDomain NSToolbarTitleViewRolloverDelay -float 0
|
||||
|
||||
log_msg "Set increased window resize speed"
|
||||
defaults write NSGlobalDomain NSWindowResizeTime -float 0.05
|
||||
|
||||
log_msg "Set file save dialog to expand to all files by default"
|
||||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
|
||||
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
|
||||
|
||||
log_msg "Set print dialog to expand to show all by default"
|
||||
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
|
||||
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
|
||||
|
||||
log_msg "Set files to save to disk, not iCloud by default"
|
||||
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
|
||||
|
||||
log_msg "Set printer app to quit once job is completed"
|
||||
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
|
||||
|
||||
log_msg "Disables the app opening confirmation dialog"
|
||||
defaults write com.apple.LaunchServices LSQuarantine -bool false
|
||||
|
||||
log_msg "Remove duplicates in the Open With menu"
|
||||
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister \
|
||||
-kill -r -domain local -domain system -domain user
|
||||
|
||||
log_msg "Show ASCII control characters using caret notation in text views"
|
||||
defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true
|
||||
|
||||
#####################################
|
||||
# System Power, Resuming, Lock, etc #
|
||||
#####################################
|
||||
log_section "System Power and Lock Screen"
|
||||
|
||||
log_msg "Disable waking on lid opening"
|
||||
sudo pmset -a lidwake 1
|
||||
|
||||
log_msg "Prevent automatic restart when power restored"
|
||||
sudo pmset -a autorestart 1
|
||||
|
||||
log_msg "Set display to sleep after 15 minutes"
|
||||
sudo pmset -a displaysleep 15
|
||||
|
||||
log_msg "Set sysyem sleep time to 30 minutes when on battery"
|
||||
sudo pmset -b sleep 30
|
||||
|
||||
log_msg "Set system to not sleep automatically when on mains power"
|
||||
sudo pmset -c sleep 0
|
||||
|
||||
log_msg "Require password immediatley after sleep or screensaver"
|
||||
defaults write com.apple.screensaver askForPassword -int 1
|
||||
defaults write com.apple.screensaver askForPasswordDelay -int 0
|
||||
|
||||
log_msg "Disable system wide resuming of windows"
|
||||
defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false
|
||||
|
||||
log_msg "Disable auto termination of inactive apps"
|
||||
defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true
|
||||
|
||||
log_msg "Disable the crash reporter"
|
||||
defaults write com.apple.CrashReporter DialogType -string "none"
|
||||
|
||||
log_msg "Add host info to the login screen"
|
||||
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
|
||||
|
||||
##############################
|
||||
# Sound and Display Settings #
|
||||
##############################
|
||||
log_section "Sound and Display"
|
||||
|
||||
log_msg "Increase sound quality for Bluetooth devivces"
|
||||
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
|
||||
|
||||
log_msg "Enable subpixel font rendering on non-Apple LCDs"
|
||||
defaults write NSGlobalDomain AppleFontSmoothing -int 1
|
||||
|
||||
log_msg "Enable HiDPI display modes"
|
||||
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
|
||||
|
||||
########################
|
||||
# Keyboard, Text Input #
|
||||
########################
|
||||
log_section "Keyboard and Input"
|
||||
|
||||
log_msg "Disable automatic text capitalization"
|
||||
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
|
||||
|
||||
log_msg "Disable automatic dash substitution"
|
||||
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
|
||||
|
||||
log_msg "Disable automatic periord substitution"
|
||||
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
|
||||
|
||||
log_msg "Disable automatic period substitution"
|
||||
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
|
||||
|
||||
log_msg "Disable automatic spell correction"
|
||||
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
|
||||
|
||||
log_msg "Enable full keyboard navigation in all windows"
|
||||
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
|
||||
|
||||
log_msg "Allow modifier key to be used for mouse zooming"
|
||||
defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true
|
||||
defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
|
||||
|
||||
log_msg "Follow the keyboard focus while zoomed in"
|
||||
defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true
|
||||
|
||||
log_msg "Set time before keys start repeating"
|
||||
defaults write NSGlobalDomain InitialKeyRepeat -int 50
|
||||
|
||||
log_msg "Set super fast key repeat rate"
|
||||
defaults write NSGlobalDomain KeyRepeat -int 8
|
||||
|
||||
log_msg "Fix UTF-8 bug in QuickLook"
|
||||
echo "0x08000100:0" > ~/.CFUserTextEncoding
|
||||
|
||||
#####################################
|
||||
# Mouse, Trackpad, Pointing Devices #
|
||||
#####################################
|
||||
log_section "Mouse and Trackpad"
|
||||
|
||||
log_msg "Enable tap to click for trackpad"
|
||||
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
|
||||
|
||||
log_msg "Enable tab to click for current user"
|
||||
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
|
||||
|
||||
log_msg "Enable tap to click for the login screen"
|
||||
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
|
||||
|
||||
log_msg "Set hot corners for trackpad"
|
||||
defaults write com.apple.dock wvous-tl-corner -int 11
|
||||
defaults write com.apple.dock wvous-tl-modifier -int 0
|
||||
defaults write com.apple.dock wvous-bl-corner -int 2
|
||||
defaults write com.apple.dock wvous-bl-modifier -int 1048576
|
||||
defaults write com.apple.dock wvous-br-corner -int 5
|
||||
defaults write com.apple.dock wvous-br-modifier -int 1048576
|
||||
defaults write com.apple.dock wvous-tr-corner -int 0
|
||||
defaults write com.apple.dock wvous-tr-modifier -int 0
|
||||
|
||||
# ##############################
|
||||
# Spotlight Search Preferences #
|
||||
# ##############################
|
||||
log_section "Spotlight and Search"
|
||||
|
||||
# Emable / disable search locations, and indexing order
|
||||
log_msg "Set Spotlight Search Locations Order"
|
||||
defaults write com.apple.spotlight orderedItems -array \
|
||||
'{"enabled" = 1;"name" = "APPLICATIONS";}' \
|
||||
'{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \
|
||||
'{"enabled" = 1;"name" = "DIRECTORIES";}' \
|
||||
'{"enabled" = 1;"name" = "PDF";}' \
|
||||
'{"enabled" = 0;"name" = "FONTS";}' \
|
||||
'{"enabled" = 0;"name" = "DOCUMENTS";}' \
|
||||
'{"enabled" = 0;"name" = "MESSAGES";}' \
|
||||
'{"enabled" = 0;"name" = "CONTACT";}' \
|
||||
'{"enabled" = 0;"name" = "EVENT_TODO";}' \
|
||||
'{"enabled" = 0;"name" = "IMAGES";}' \
|
||||
'{"enabled" = 0;"name" = "BOOKMARKS";}' \
|
||||
'{"enabled" = 0;"name" = "MUSIC";}' \
|
||||
'{"enabled" = 0;"name" = "MOVIES";}' \
|
||||
'{"enabled" = 0;"name" = "PRESENTATIONS";}' \
|
||||
'{"enabled" = 0;"name" = "SPREADSHEETS";}' \
|
||||
'{"enabled" = 0;"name" = "SOURCE";}' \
|
||||
'{"enabled" = 0;"name" = "MENU_DEFINITION";}' \
|
||||
'{"enabled" = 0;"name" = "MENU_OTHER";}' \
|
||||
'{"enabled" = 0;"name" = "MENU_CONVERSION";}' \
|
||||
'{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \
|
||||
'{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \
|
||||
'{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}'
|
||||
|
||||
# Spotlight - load new settings, enable indexing, and rebuild index
|
||||
log_msg "Refreshing Spotlight"
|
||||
killall mds > /dev/null 2>&1
|
||||
sudo mdutil -i on / > /dev/null
|
||||
sudo mdutil -E / > /dev/null
|
||||
|
||||
###############################
|
||||
# Dock and Launchpad Settings #
|
||||
###############################
|
||||
log_section "Dock and Launchpad"
|
||||
|
||||
log_msg "Add highlight effect to dock stacks"
|
||||
defaults write com.apple.dock mouse-over-hilite-stack -bool true
|
||||
|
||||
log_msg "Set item size within dock stacks"
|
||||
defaults write com.apple.dock tilesize -int 24
|
||||
|
||||
log_msg "Set dock to use genie animation"
|
||||
defaults write com.apple.dock mineffect -string "genie"
|
||||
|
||||
log_msg "Set apps to minimize into their dock icon"
|
||||
defaults write com.apple.dock minimize-to-application -bool true
|
||||
|
||||
log_msg "Enable spring loading, for opening files by dragging to dock"
|
||||
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true
|
||||
|
||||
log_msg "Enable process indicator for apps within dock"
|
||||
defaults write com.apple.dock show-process-indicators -bool true
|
||||
|
||||
log_msg "Enable app launching animations"
|
||||
defaults write com.apple.dock launchanim -bool true
|
||||
|
||||
log_msg "Set opening animation speed"
|
||||
defaults write com.apple.dock expose-animation-duration -float 1
|
||||
|
||||
log_msg "Disable auntomatic rearanging of spaces"
|
||||
defaults write com.apple.dock mru-spaces -bool false
|
||||
|
||||
log_msg "Set dock to auto-hide by default"
|
||||
defaults write com.apple.dock autohide -bool true
|
||||
|
||||
log_msg "Set the dock's auto-hide delay to fast"
|
||||
defaults write com.apple.dock autohide-delay -float 0.05
|
||||
|
||||
log_msg "Set the dock show / hide animation time"
|
||||
defaults write com.apple.dock autohide-time-modifier -float 0.25
|
||||
|
||||
log_msg "Show which dock apps are hidden"
|
||||
defaults write com.apple.dock showhidden -bool true
|
||||
|
||||
log_msg "Hide recent files from the dock"
|
||||
defaults write com.apple.dock show-recents -bool false
|
||||
|
||||
# If DockUtil installed, then use it to remove default dock items, and add useful ones
|
||||
if hash dockutil 2> /dev/null; then
|
||||
apps_to_remove_from_dock=(
|
||||
'App Store' 'Calendar' 'Contacts' 'FaceTime'
|
||||
'Keynote' 'Mail' 'Maps' 'Messages' 'Music'
|
||||
'News' 'Notes' 'Numbers'
|
||||
'Pages' 'Photos' 'Podcasts'
|
||||
'Reminders' 'TV'
|
||||
)
|
||||
apps_to_add_to_dock=(
|
||||
'iTerm' 'Firefox' 'Standard Notes' 'Visual Studio Code'
|
||||
)
|
||||
IFS=""
|
||||
# Removes useless apps from dock
|
||||
for app in ${apps_to_remove_from_dock[@]}; do
|
||||
dockutil --remove ~/Applications/${app}.app
|
||||
done
|
||||
# Adds useful apps to dock, if installed
|
||||
for app in ${apps_to_add_to_dock[@]}; do
|
||||
if [[ -d "~/Applications/${app}.app" ]]; then
|
||||
dockutil --add ~/Applications/${app}.app
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
log_msg "Add iOS Simulator to Launchpad"
|
||||
sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/Simulator.app"
|
||||
|
||||
log_msg "Add Apple Watch simulator to Launchpad"
|
||||
sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator (Watch).app" "/Applications/Simulator (Watch).app"
|
||||
|
||||
|
||||
#####################################
|
||||
# Print finishing message, and exit #
|
||||
#####################################
|
||||
echo -e "${PRIMARY_COLOR}\nFinishing...${RESET_COLOR}"
|
||||
echo -e "${SUCCESS_COLOR}✔ ${current_event}/${total_events} tasks were completed \
|
||||
succesfully in $((`date +%s`-start_time)) seconds${RESET_COLOR}"
|
||||
echo -e "\n${PRIMARY_COLOR} .:'\n __ :'__\n .'\`__\`-'__\`\`.\n \
|
||||
:__________.-'\n :_________:\n :_________\`-;\n \`.__.-.__.'\n${RESET_COLOR}"
|
||||
|
||||
if [[ ! $params == *"--quick-exit"* ]]; then
|
||||
echo -e "${ACCENT_COLOR}Press any key to continue.${RESET_COLOR}"
|
||||
read -t 5 -n 1 -s
|
||||
fi
|
||||
exit 0
|
272
system-specific/macos/system-settings/macos-security.sh
Executable file
272
system-specific/macos/system-settings/macos-security.sh
Executable file
@ -0,0 +1,272 @@
|
||||
#!/bin/bash
|
||||
|
||||
##############################################################################
|
||||
# Security improvments for Mac OS systems #
|
||||
# Covers Siri, firewall, account security, connections and network protocols #
|
||||
# #
|
||||
# CAUTION: This script will apply changes to your OS X system configuration #
|
||||
# Be sure to read it through carefully, and remove anything you don't want. #
|
||||
# #
|
||||
# Options: #
|
||||
# --silent - Don't log any status outputs #
|
||||
# --skip-intro - Skip the warning and intro section #
|
||||
# --yes-to-all - Don't ptompt user to agree to changes #
|
||||
# #
|
||||
# Licensed under MIT - (C) Alicia Sykes 2022 <https://aliciasykes.com> #
|
||||
##############################################################################
|
||||
|
||||
############################################################
|
||||
# Initialize variables, check requirements, and print info #
|
||||
############################################################
|
||||
|
||||
# Record start time
|
||||
start_time=`date +%s`
|
||||
|
||||
# Get params
|
||||
params="$params $*"
|
||||
|
||||
# Color variables
|
||||
PRIMARY_COLOR='\033[1;33m'
|
||||
ACCENT_COLOR='\033[0;34m'
|
||||
INFO_COLOR='\033[0;30m'
|
||||
INFO_COLOR_U='\033[4;30m'
|
||||
SUCCESS_COLOR='\033[0;32m'
|
||||
WARN_1='\033[1;31m'
|
||||
WARN_2='\033[0;31m'
|
||||
RESET_COLOR='\033[0m'
|
||||
|
||||
# Current and total taslks, used for progress updates
|
||||
current_event=0
|
||||
total_events=25
|
||||
|
||||
if [ ! "$(uname -s)" = "Darwin" ]; then
|
||||
echo -e "${PRIMARY_COLOR}Incompatible System${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}This script is specific to Mac OS,\
|
||||
and only intended to be run on Darwin-based systems${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! $params == *"--skip-intro"* ]]; then
|
||||
# Prints intro message
|
||||
echo -e "${PRIMARY_COLOR} MacOS Security Settings${RESET_COLOR}"
|
||||
echo -e "${ACCENT_COLOR}The following options will be applied:"
|
||||
echo -e " - Disabling Siri and voice feedback"
|
||||
echo -e " - Configures firewall for security"
|
||||
echo -e " - Apply login + screen security settings"
|
||||
echo -e " - Prevent unauthorised connections"
|
||||
echo -e " - Disable printer and sharing protocols"
|
||||
|
||||
# Informs user what they're running, and cautions them to read first
|
||||
echo -e "\n${INFO_COLOR}You are running ${0} on\
|
||||
$(hostname -f | sed -e 's/^[^.]*\.//') as $(id -un)${RESET_COLOR}"
|
||||
echo -e "${WARN_1}IMPORTANT:${WARN_2} This script will make changes to your system."
|
||||
echo -e "${WARN_2}Ensure that you've read it through before continuing.${RESET_COLOR}"
|
||||
|
||||
# Ask for user confirmation before proceeding (if skip flag isn't passed)
|
||||
if [[ ! $params == *"--yes-to-all"* ]]; then
|
||||
echo -e "\n${PRIMARY_COLOR}Would you like to proceed? (y/N)${RESET_COLOR}"
|
||||
read -t 15 -n 1 -r
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo -e "${ACCENT_COLOR}\nNo worries, nothing will be applied - feel free to come back another time."
|
||||
echo -e "${PRIMARY_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# Check have got admin privilages
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${ACCENT_COLOR}\nElevated permissions are required to adjust system settings."
|
||||
echo -e "${PRIMARY_COLOR}Please enter your password...${RESET_COLOR}"
|
||||
script_path=$([[ "$0" = /* ]] && echo "$0" || echo "$PWD/${0#./}")
|
||||
params="--skip-intro ${params}"
|
||||
sudo "$script_path" $params || (
|
||||
echo -e "${ACCENT_COLOR}Unable to continue without sudo permissions"
|
||||
echo -e "${PRIMARY_COLOR}Exiting...${RESET_COLOR}"
|
||||
exit 1
|
||||
)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Helper function to log progress to console
|
||||
function log_msg () {
|
||||
current_event=$(($current_event + 1))
|
||||
if [[ ! $params == *"--silent"* ]]; then
|
||||
if (("$current_event" < 10 )); then sp='0'; else sp=''; fi
|
||||
echo -e "${PRIMARY_COLOR}[${sp}${current_event}/${total_events}] ${ACCENT_COLOR}${1}${INFO_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper function to log section to console
|
||||
function log_section () {
|
||||
if [[ ! $params == *"--silent"* ]]; then
|
||||
echo -e "${PRIMARY_COLOR}[INFO ] ${1}${INFO_COLOR}"
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "\n${PRIMARY_COLOR}Starting...${RESET_COLOR}"
|
||||
|
||||
# Quit System Preferences before starting
|
||||
osascript -e 'tell application "System Preferences" to quit'
|
||||
|
||||
# ######################################
|
||||
# Disabling Siri and related features #
|
||||
# ######################################
|
||||
log_section "Disable Assistant Features"
|
||||
|
||||
# Disable Ask Siri
|
||||
log_msg "Disable 'Ask Siri'"
|
||||
defaults write com.apple.assistant.support 'Assistant Enabled' -bool false
|
||||
|
||||
# Disable Siri voice feedback
|
||||
log_msg "Disable Siri voice feedback"
|
||||
defaults write com.apple.assistant.backedup 'Use device speaker for TTS' -int 3
|
||||
|
||||
# Disable Siri services (Siri and assistantd)
|
||||
log_msg "Disable Siri services (Siri and assistantd)"
|
||||
launchctl disable "user/$UID/com.apple.assistantd"
|
||||
launchctl disable "gui/$UID/com.apple.assistantd"
|
||||
sudo launchctl disable 'system/com.apple.assistantd'
|
||||
launchctl disable "user/$UID/com.apple.Siri.agent"
|
||||
launchctl disable "gui/$UID/com.apple.Siri.agent"
|
||||
sudo launchctl disable 'system/com.apple.Siri.agent'
|
||||
if [ $(/usr/bin/csrutil status | awk '/status/ {print $5}' | sed 's/\.$//') = "enabled" ]; then
|
||||
>&2 echo 'This script requires SIP to be disabled. Read more: \
|
||||
https://developer.apple.com/documentation/security/disabling_and_enabling_system_integrity_protection'
|
||||
fi
|
||||
|
||||
# Disable "Do you want to enable Siri?" pop-up
|
||||
log_msg "Disable 'Do you want to enable Siri?' pop-up"
|
||||
defaults write com.apple.SetupAssistant 'DidSeeSiriSetup' -bool True
|
||||
|
||||
# Hide Siri from menu bar
|
||||
log_msg "Hide Siri from menu bar"
|
||||
defaults write com.apple.systemuiserver 'NSStatusItem Visible Siri' 0
|
||||
|
||||
# Hide Siri from status menu
|
||||
log_msg "Hide Siri from status menu"
|
||||
defaults write com.apple.Siri 'StatusMenuVisible' -bool false
|
||||
defaults write com.apple.Siri 'UserHasDeclinedEnable' -bool true
|
||||
|
||||
# Opt-out from Siri data collection
|
||||
log_msg "Opt-out from Siri data collection"
|
||||
defaults write com.apple.assistant.support 'Siri Data Sharing Opt-In Status' -int 2
|
||||
|
||||
|
||||
############################
|
||||
# MacOS Firefwall Security #
|
||||
############################
|
||||
log_section "Firewall Config"
|
||||
|
||||
# Prevent automatically allowing incoming connections to signed apps
|
||||
log_msg "Prevent automatically allowing incoming connections to signed apps"
|
||||
sudo defaults write /Library/Preferences/com.apple.alf allowsignedenabled -bool false
|
||||
|
||||
# Prevent automatically allowing incoming connections to downloaded signed apps
|
||||
log_msg "Prevent automatically allowing incoming connections to downloaded signed apps"
|
||||
sudo defaults write /Library/Preferences/com.apple.alf allowdownloadsignedenabled -bool false
|
||||
|
||||
# Enable application firewall
|
||||
log_msg "Enable application firewall"
|
||||
/usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
|
||||
sudo defaults write /Library/Preferences/com.apple.alf globalstate -bool true
|
||||
defaults write com.apple.security.firewall EnableFirewall -bool true
|
||||
|
||||
# Turn on firewall logging
|
||||
log_msg "Turn on firewall logging"
|
||||
/usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode on
|
||||
sudo defaults write /Library/Preferences/com.apple.alf loggingenabled -bool true
|
||||
|
||||
# Turn on stealth mode
|
||||
log_msg "Turn on stealth mode"
|
||||
/usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
|
||||
sudo defaults write /Library/Preferences/com.apple.alf stealthenabled -bool true
|
||||
defaults write com.apple.security.firewall EnableStealthMode -bool true
|
||||
|
||||
|
||||
####################################
|
||||
# Log In and User Account Security #
|
||||
####################################
|
||||
log_section "Account Security"
|
||||
|
||||
# Require a password to wake the computer from sleep or screen saver
|
||||
log_msg "Require a password to wake the computer from sleep or screen saver"
|
||||
sudo defaults write /Library/Preferences/com.apple.screensaver askForPassword -bool true
|
||||
|
||||
# Initiate session lock five seconds after screen saver is started
|
||||
log_msg "Initiate session lock five seconds after screen saver is started"
|
||||
sudo defaults write /Library/Preferences/com.apple.screensaver 'askForPasswordDelay' -int 5
|
||||
|
||||
# Disables signing in as Guest from the login screen
|
||||
|
||||
log_msg "Disables signing in as Guest from the login screen"
|
||||
sudo defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool NO
|
||||
|
||||
# Disables Guest access to file shares over AF
|
||||
log_msg "Disables Guest access to file shares over AF"
|
||||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO
|
||||
|
||||
|
||||
####################################
|
||||
# Prevent Unauthorized Connections #
|
||||
####################################
|
||||
log_section "Prevent Unauthorized Connections"
|
||||
|
||||
# Disables Guest access to file shares over SMB
|
||||
log_msg "Disables Guest access to file shares over SMB"
|
||||
sudo defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO
|
||||
|
||||
# Disable remote login (incoming SSH and SFTP connections)
|
||||
log_msg "Disable remote login (incoming SSH and SFTP connections)"
|
||||
echo 'yes' | sudo systemsetup -setremotelogin off
|
||||
|
||||
# Disable insecure TFTP service
|
||||
log_msg "Disable insecure TFTP service"
|
||||
sudo launchctl disable 'system/com.apple.tftpd'
|
||||
|
||||
# Disable Bonjour multicast advertising
|
||||
log_msg "Disable Bonjour multicast advertising"
|
||||
sudo defaults write /Library/Preferences/com.apple.mDNSResponder.plist NoMulticastAdvertisements -bool true
|
||||
|
||||
# Disable insecure telnet protocol
|
||||
log_msg "Disable insecure telnet protocol"
|
||||
sudo launchctl disable system/com.apple.telnetd
|
||||
|
||||
|
||||
#########################################
|
||||
# Disable Printers and Sharing Protocols #
|
||||
#########################################
|
||||
log_section "Printers and Sharing Protocols"
|
||||
|
||||
# Disable sharing of local printers with other computers
|
||||
log_msg "Disable sharing of local printers with other computers"
|
||||
cupsctl --no-share-printers
|
||||
|
||||
# Disable printing from any address including the Internet
|
||||
log_msg "Disable printing from any address including the Internet"
|
||||
cupsctl --no-remote-any
|
||||
|
||||
# Disable remote printer administration
|
||||
log_msg "Disable remote printer administration"
|
||||
cupsctl --no-remote-admin
|
||||
|
||||
# Disable Captive portal
|
||||
log_msg "Disable Captive portal"
|
||||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.captive.control.plist Active -bool false
|
||||
|
||||
#####################################
|
||||
# Print finishing message, and exit #
|
||||
#####################################
|
||||
echo -e "${PRIMARY_COLOR}\nFinishing...${RESET_COLOR}"
|
||||
echo -e "${SUCCESS_COLOR}✔ ${current_event}/${total_events} tasks were completed \
|
||||
succesfully in $((`date +%s`-start_time)) seconds${RESET_COLOR}"
|
||||
echo -e "\n${PRIMARY_COLOR} .:'\n __ :'__\n .'\`__\`-'__\`\`.\n \
|
||||
:__________.-'\n :_________:\n :_________\`-;\n \`.__.-.__.'\n${RESET_COLOR}"
|
||||
|
||||
if [[ ! $params == *"--quick-exit"* ]]; then
|
||||
echo -e "${ACCENT_COLOR}Press any key to continue.${RESET_COLOR}"
|
||||
read -t 5 -n 1 -s
|
||||
fi
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user