From 5685e01a105a58d8580c6b4acd61dc370df49752 Mon Sep 17 00:00:00 2001 From: Louis Borsu Date: Sat, 28 Mar 2026 22:48:12 +0100 Subject: [PATCH] feat(osx): update the tweaks for osx 15.6 --- roles/osx/templates/osx_tweaks.sh.j2 | 202 +++++++++++++++++++-------- 1 file changed, 146 insertions(+), 56 deletions(-) diff --git a/roles/osx/templates/osx_tweaks.sh.j2 b/roles/osx/templates/osx_tweaks.sh.j2 index bbff1d9..66e1d3f 100644 --- a/roles/osx/templates/osx_tweaks.sh.j2 +++ b/roles/osx/templates/osx_tweaks.sh.j2 @@ -1,8 +1,8 @@ #!/usr/bin/env bash -# Close any open System Preferences panes, to prevent them from overriding -# settings we’re about to change -osascript -e 'tell application "System Preferences" to quit' +# Close any open System Settings panes, to prevent them from overriding +# settings we're about to change +osascript -e 'tell application "System Settings" to quit' # Ask for the administrator password upfront sudo -v @@ -14,14 +14,15 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & # General UI/UX # ############################################################################### -# Set computer name (as done via System Preferences → Sharing) -sudo scutil --set ComputerName "SatUFO" -sudo scutil --set HostName "SatUFO" -sudo scutil --set LocalHostName "SatUFO" +# Set computer name (as done via System Settings → Sharing) +sudo scutil --set ComputerName "SatAirUFO" +sudo scutil --set HostName "SatAirUFO" +sudo scutil --set LocalHostName "SatAirUFO" sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "SatUFO" -# Disable the sound effects on boot -sudo nvram SystemAudioVolume=" " +# Disable the startup sound +# (SystemAudioVolume is ignored on Apple Silicon — use StartupMute instead) +sudo nvram StartupMute=%01 # Set highlight color to orange defaults write NSGlobalDomain AppleHighlightColor -string "1.000000 0.874510 0.701961 Orange" @@ -55,10 +56,10 @@ defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false # Automatically quit printer app once the print jobs complete defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true -# Disable the “Are you sure you want to open this application?” dialog +# Disable the "Are you sure you want to open this application?" dialog defaults write com.apple.LaunchServices LSQuarantine -bool false -# Remove duplicates in the “Open With” menu (also see `lscleanup` alias) +# Remove duplicates in the "Open With" menu (also see `lscleanup` alias) /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user # Display ASCII control characters using caret notation in standard text views @@ -78,20 +79,16 @@ defaults write com.apple.helpviewer DevMode -bool true # in the login window sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName -# Disable Notification Center and remove the menu bar icon -launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null -killall NotificationCenter - -# Disable automatic capitalization as it’s annoying when typing code +# Disable automatic capitalization as it's annoying when typing code defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false -# Disable smart dashes as they’re annoying when typing code +# Disable smart dashes as they're annoying when typing code defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false -# Disable automatic period substitution as it’s annoying when typing code +# Disable automatic period substitution as it's annoying when typing code defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false -# Disable smart quotes as they’re annoying when typing code +# Disable smart quotes as they're annoying when typing code defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false # Disable auto-correct @@ -101,8 +98,7 @@ defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false # Trackpad, mouse, keyboard, Bluetooth accessories, and input # ############################################################################### - -# Disable “natural” (Lion-style) scrolling +# Disable "natural" (Lion-style) scrolling defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false # Increase sound quality for Bluetooth headphones/headsets @@ -113,10 +109,10 @@ defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 # Use scroll gesture with the Ctrl (^) modifier key to zoom -defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true -defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 +sudo defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true +sudo defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 # Follow the keyboard focus while zoomed in -defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true +sudo defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true # Disable press-and-hold for keys in favor of key repeat defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false @@ -134,8 +130,11 @@ defaults write NSGlobalDomain AppleMetricUnits -bool true # Show language menu in the top right corner of the boot screen sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true -# Set the timezone; see `sudo systemsetup -listtimezones` for other values -sudo systemsetup -settimezone "Europe/Brussels" > /dev/null +# Set the timezone +# Note: systemsetup is deprecated in macOS 14+ but still functional in 15.x +# Using full path to avoid PATH issues; falling back to defaults write if it fails +sudo /usr/sbin/systemsetup -settimezone "Europe/Brussels" 2>/dev/null || \ + sudo defaults write /Library/Preferences/.GlobalPreferences.plist com.apple.TimeZone -string "Europe/Brussels" ############################################################################### # Screen # @@ -145,8 +144,15 @@ sudo systemsetup -settimezone "Europe/Brussels" > /dev/null defaults write com.apple.screensaver askForPassword -int 1 defaults write com.apple.screensaver askForPasswordDelay -int 0 -# Save screenshots in Dropbox -defaults write com.apple.screencapture location -string "${HOME}/Dropbox/Screenshots" +# Save screenshots to Dropbox if available, otherwise fall back to Desktop +if [ -d "${HOME}/Dropbox" ]; then + mkdir -p "${HOME}/Dropbox/Screenshots" + defaults write com.apple.screencapture location -string "${HOME}/Dropbox/Screenshots" + echo "Dropbox found — screenshots will be saved to ~/Dropbox/Screenshots" +else + defaults write com.apple.screencapture location -string "${HOME}/Desktop" + echo "Dropbox not found — screenshots will be saved to ~/Desktop" +fi # Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) defaults write com.apple.screencapture type -string "png" @@ -154,6 +160,12 @@ defaults write com.apple.screencapture type -string "png" # Disable shadow in screenshots defaults write com.apple.screencapture disable-shadow -bool true +# Include date in screenshot filenames +defaults write com.apple.screencapture include-date -bool true + +# Disable floating thumbnail preview after taking a screenshot +defaults write com.apple.screencapture show-thumbnail -bool false + # Enable subpixel font rendering on non-Apple LCDs # Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 defaults write NSGlobalDomain AppleFontSmoothing -int 1 @@ -171,9 +183,14 @@ defaults write com.apple.finder QuitMenuItem -bool true # Finder: disable window animations and Get Info animations defaults write com.apple.finder DisableAllAnimations -bool true -# Set Dropbox as the default location for new Finder windows -defaults write com.apple.finder NewWindowTarget -string "PfLo" -defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Dropbox/" +# Set Dropbox as the default location for new Finder windows (if available) +if [ -d "${HOME}/Dropbox" ]; then + defaults write com.apple.finder NewWindowTarget -string "PfLo" + defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Dropbox/" +else + defaults write com.apple.finder NewWindowTarget -string "PfHm" + defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/" +fi # Hide all icons on the desktop defaults write com.apple.finder CreateDesktop false @@ -187,6 +204,9 @@ defaults write NSGlobalDomain AppleShowAllExtensions -bool true # Finder: show status bar defaults write com.apple.finder ShowStatusBar -bool true +# Finder: show path bar +defaults write com.apple.finder ShowPathbar -bool true + # Display full POSIX path as Finder window title defaults write com.apple.finder _FXShowPosixPathInTitle -bool true @@ -219,25 +239,28 @@ defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true -# Use list view in all Finder windows by default +# Use column view in all Finder windows by default # Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv` defaults write com.apple.finder FXPreferredViewStyle -string "clmv" # Enable AirDrop over Ethernet and on unsupported Macs running Lion defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true +# Show the ~/Library folder +chflags nohidden ~/Library + # Show the /Volumes folder sudo chflags nohidden /Volumes # Expand the following File Info panes: -# “General”, “Open with”, and “Sharing & Permissions” +# "General", "Open with", and "Sharing & Permissions" defaults write com.apple.finder FXInfoPanesExpanded -dict \ General -bool true \ OpenWith -bool true \ Privileges -bool true ############################################################################### -# Dock, Dashboard, and hot corners # +# Dock and hot corners # ############################################################################### # Set the icon size of Dock items to 36 pixels @@ -246,7 +269,7 @@ defaults write com.apple.dock tilesize -int 36 # Change minimize/maximize window effect defaults write com.apple.dock mineffect -string "scale" -# Minimize windows into their application’s icon +# Minimize windows into their application's icon defaults write com.apple.dock minimize-to-application -bool true # Enable spring loading for all Dock items @@ -256,30 +279,24 @@ defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true defaults write com.apple.dock show-process-indicators -bool true # Wipe all (default) app icons from the Dock -# This is only really useful when setting up a new Mac, or if you don’t use +# This is only really useful when setting up a new Mac, or if you don't use # the Dock to launch apps. #defaults write com.apple.dock persistent-apps -array # Show only open applications in the Dock #defaults write com.apple.dock static-only -bool true -# Don’t animate opening applications from the Dock +# Don't animate opening applications from the Dock defaults write com.apple.dock launchanim -bool false # Speed up Mission Control animations defaults write com.apple.dock expose-animation-duration -float 0.1 -# Don’t group windows by application in Mission Control +# Don't group windows by application in Mission Control # (i.e. use the old Exposé behavior instead) defaults write com.apple.dock expose-group-by-app -bool false -# Disable Dashboard -defaults write com.apple.dashboard mcx-disabled -bool true - -# Don’t show Dashboard as a Space -defaults write com.apple.dock dashboard-in-overlay -bool true - -# Don’t automatically rearrange Spaces based on most recent use +# Don't automatically rearrange Spaces based on most recent use defaults write com.apple.dock mru-spaces -bool false # Remove the auto-hiding Dock delay @@ -295,7 +312,7 @@ defaults write com.apple.dock recent-apps -array # Put Dock on the left defaults write com.apple.dock orientation -string "left" -# Set doublick click on window title to zoom +# Set double-click on window title to zoom defaults write -g AppleActionOnDoubleClick -string "Maximize" # Automatically hide and show the Dock @@ -304,15 +321,14 @@ defaults write com.apple.dock autohide -bool true # Make Dock icons of hidden applications translucent defaults write com.apple.dock showhidden -bool true -# Don’t show recent applications in Dock +# Don't show recent applications in Dock defaults write com.apple.dock show-recents -bool false # Disable the Launchpad gesture (pinch with thumb and three fingers) defaults write com.apple.dock showLaunchpadGestureEnabled -int 0 # Reset Launchpad, but keep the desktop wallpaper intact -find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete - +find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -type f -delete 2>/dev/null || true # Hot corners # Possible values: @@ -322,27 +338,101 @@ find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -dele # 4: Desktop # 5: Start screen saver # 6: Disable screen saver -# 7: Dashboard # 10: Put display to sleep # 11: Launchpad # 12: Notification Center # 13: Lock Screen -# Top left screen corner → Mission Control +# Top left screen corner → no-op defaults write com.apple.dock wvous-tl-corner -int 0 defaults write com.apple.dock wvous-tl-modifier -int 0 -# Top right screen corner → Desktop +# Top right screen corner → no-op defaults write com.apple.dock wvous-tr-corner -int 0 defaults write com.apple.dock wvous-tr-modifier -int 0 -# Bottom left screen corner → Start screen saver +# Bottom left screen corner → no-op defaults write com.apple.dock wvous-bl-corner -int 0 defaults write com.apple.dock wvous-bl-modifier -int 0 +############################################################################### +# Mission Control / Spaces # +############################################################################### + +# Displays have separate Spaces (important for multi-monitor workflows) +defaults write com.apple.spaces spans-displays -bool false + +# Switch to a Space with open windows for the application when switching apps +defaults write NSGlobalDomain AppleSpacesSwitchOnActivate -bool true + ############################################################################### # Spotlight # ############################################################################### -# Disable Spotlight -sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist +# Disable Spotlight indexing +# Note: launchctl unload is deprecated; use mdutil to disable indexing instead. +# To fully disable via launchctl (requires SIP off): sudo launchctl bootout system/com.apple.metadata.mds +sudo mdutil -a -i off + +############################################################################### +# Terminal # +############################################################################### + +# Enable secure keyboard entry in Terminal.app +# (prevents other apps from reading keystrokes while Terminal is focused) +defaults write com.apple.terminal SecureKeyboardEntry -bool true + +# Disable the line marks in Terminal +defaults write com.apple.Terminal ShowLineMarks -int 0 + +# Only use UTF-8 in Terminal.app +defaults write com.apple.terminal StringEncodings -array 4 + +############################################################################### +# Privacy # +############################################################################### + +# Disable Siri completely +defaults write com.apple.assistant.support 'Assistant Enabled' -bool false +defaults write com.apple.Siri SiriPrefStashedStatusMenuVisible -bool false +defaults write com.apple.Siri StatusMenuVisible -bool false +defaults write com.apple.SystemUIServer 'NSStatusItem Visible Siri' -bool false + +# Disable crash reporter dialogs +defaults write com.apple.CrashReporter DialogType -string "none" +defaults write com.apple.CrashReporter UseUNC -int 0 + +# Disable personalized ads +defaults write com.apple.AdLib allowApplePersonalizedAdvertising -bool false + +# Disable Feedback Assistant auto-gather +defaults write com.apple.appleseed.FeedbackAssistant Autogather -bool false + +############################################################################### +# Performance & Power # +############################################################################### + +# Disable hibernation (speeds up sleep/wake; safe on Apple Silicon with SSD) +sudo pmset -a hibernatemode 0 + +# Remove the sleep image to reclaim disk space (only safe after setting hibernatemode 0) +sudo rm -f /private/var/vm/sleepimage +sudo touch /private/var/vm/sleepimage +sudo chflags uchg /private/var/vm/sleepimage + +# Disable the sudden motion sensor (no-op on Apple Silicon but harmless) +sudo pmset -a sms 0 + +# Disable wake on network access +sudo systemsetup -setwakeonnetworkaccess off 2>/dev/null || true + +############################################################################### +# Developer ergonomics # +############################################################################### + +# Expand Git diffs in Quick Look +defaults write com.apple.finder QLEnableXRayFolders -bool true + +# Note: to raise the open file descriptor limit for Node.js / Docker work, +# add the following to your ~/.zshrc: +# ulimit -n 10240 ############################################################################### # Time Machine # @@ -366,7 +456,7 @@ defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" defaults write com.apple.ActivityMonitor SortDirection -int 0 ############################################################################### -# TextEdit, and Disk Utility # +# TextEdit and Disk Utility # ############################################################################### # Use plain text mode for new TextEdit documents