From e71962c89fb8bd0f24a2ba332a7c87beb81728db Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Sat, 17 Oct 2026 21:19:38 -0400 Subject: [PATCH] feat(macos): configure system preferences --- README.md | 24 +++++++++++++ home/.chezmoiignore | 1 + home/bin/executable_setup-macos.sh | 58 ++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 home/bin/executable_setup-macos.sh diff --git a/README.md b/README.md index 613c822..96ab277 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,30 @@ To install newly added macOS dependencies later: brew bundle --file="$(chezmoi source-path ~/.brewfile)" ``` +### macOS system preferences + +After applying the dotfiles, review and run the optional setup script as your +normal user (not with `sudo`): + +```bash +~/bin/setup-macos.sh --dry-run +~/bin/setup-macos.sh +``` + +It enables dark mode and Dock auto-hide; disables natural +scrolling and swipe-to-navigate; and removes window-tiling margins (macOS Sequoia +and later). It does not change animation settings: macOS does not provide a +supported speed control for desktop-switching animations. + +These are curated preferences observed on the existing Mac, not an exhaustive +comparison against factory defaults. +App history, Dock contents, monitor/Spaces layouts, and other machine-specific +state are deliberately excluded. The script is safe to rerun but does not back +up previous values or run automatically during `chezmoi apply`. + +Close System Settings before running it. Log out and back in if changes are not +visible; the script does not restart apps or your session. + ### Hover window focus on macOS AutoRaise focuses and brings a window to the front on hover without an intentional delay or diff --git a/home/.chezmoiignore b/home/.chezmoiignore index d54b12d..19ef2f4 100644 --- a/home/.chezmoiignore +++ b/home/.chezmoiignore @@ -54,4 +54,5 @@ bin/video/cr3todng.sh {{ if ne .chezmoi.os "darwin" -}} .config/karabiner .config/AutoRaise +bin/setup-macos.sh {{ end -}} diff --git a/home/bin/executable_setup-macos.sh b/home/bin/executable_setup-macos.sh new file mode 100644 index 0000000..53a45c4 --- /dev/null +++ b/home/bin/executable_setup-macos.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# Apply curated macOS preferences without copying machine-specific state. + +set -euo pipefail + +function usage { + echo "Usage: ${0##*/} [--dry-run]" + echo "Apply macOS preferences for the current user. Do not run with sudo." +} + +dry_run=false +case "${1:-}" in + --dry-run) dry_run=true ;; + --help|-h) usage; exit 0 ;; + "") ;; + *) usage >&2; exit 1 ;; +esac +if [[ $# -gt 1 ]]; then + usage >&2 + exit 1 +fi + +if [[ "$(uname -s)" != "Darwin" ]]; then + echo "This script only supports macOS." >&2 + exit 1 +fi +if [[ "$EUID" -eq 0 ]]; then + echo "Run this script as your normal user, not with sudo." >&2 + exit 1 +fi + +function write_preference { + if [[ "$dry_run" == true ]]; then + printf '%q ' defaults write "$@" + printf '\n' + elif ! defaults write "$@"; then + echo "Could not write preference: $1 $2" >&2 + exit 1 + fi +} + +# Existing preferences observed on this Mac. This is not a full defaults export: +# macOS also stores stock values, histories, and hardware-specific state there. + +# Use dark appearance and automatically hide the Dock. +write_preference NSGlobalDomain AppleInterfaceStyle -string Dark +write_preference com.apple.dock autohide -bool true + +# Use traditional scrolling and disable swipe-based back/forward navigation. +write_preference NSGlobalDomain com.apple.swipescrolldirection -bool false +write_preference NSGlobalDomain AppleEnableSwipeNavigateWithScrolls -bool false + +# Remove the gaps around tiled windows (macOS Sequoia and later). +write_preference com.apple.WindowManager EnableTiledWindowMargins -bool false + +if [[ "$dry_run" == false ]]; then + echo "Preferences saved. Log out and back in if changes are not visible." +fi