diff --git a/bin/dcp-install-links b/bin/dcp-install-links index f82acec..7d3023a 100755 --- a/bin/dcp-install-links +++ b/bin/dcp-install-links @@ -3,16 +3,16 @@ set -eo pipefail readonly OS="$(uname -s)" -readonly NON_DCP_DOTFILES=( \ - .bash_login \ - .profile \ - .zlogin \ +readonly NON_DCP_DOTFILES=( + ".bash_login" + ".profile" + ".zlogin" ) readonly DCP_CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/dcp" readonly WARNING_SHOWN_FLAG_PATH="${DCP_CONFIG_DIR}/symlink-warning-shown" -readonly PATH_MIGRATIONS=( \ - "${HOME}/.dcp/conf/plugins:${DCP_CONFIG_DIR}/plugins.lst" \ - "${HOME}/.dcp/conf/theme:${DCP_CONFIG_DIR}/zsh-theme" \ +readonly PATH_MIGRATIONS=( + "${HOME}/.dcp/conf/plugins:${DCP_CONFIG_DIR}/plugins.lst" + "${HOME}/.dcp/conf/theme:${DCP_CONFIG_DIR}/zsh-theme" ) warnfln() { @@ -57,8 +57,9 @@ if [[ "${OS}" = "Darwin" ]]; then else link_dotfile() { case "$(basename "$1")" in - khdrc|kwm|osx) : ;; - *) __link_dotfile "$@" + khdrc|kwm|macos) : ;; + *) + __link_dotfile "$@" esac } fi @@ -67,7 +68,10 @@ standard_cleanup() { if [[ "${OS}" = "Darwin" && ! -e "${HOME}/.hushlogin" ]]; then touch "${HOME}/.hushlogin" fi - if [[ "${OS}" != "Darwin" && -h "${HOME}/.osx" ]]; then + if [[ "${OS}" != "Darwin" && -h "${HOME}/.macos" ]]; then + rm -f "${HOME}/.macos" + fi + if [[ -h "${HOME}/.osx" ]]; then rm -f "${HOME}/.osx" fi if [[ -h "${HOME}/.gitignore_global" ]]; then @@ -189,7 +193,6 @@ main() { fi if command -v git >/dev/null; then - # Only Git Things (tm) configure_git fi } diff --git a/dot/macos b/dot/macos new file mode 100755 index 0000000..2fed6f8 --- /dev/null +++ b/dot/macos @@ -0,0 +1,178 @@ +#!/bin/bash + +readonly APPS=( + "Activity Monitor" + "Disk Utility" + "Dock" + "Finder" + "SystemUIServer" + "TextEdit" +) +readonly LAUNCH_AGENTS=( + "com.apple.cfprefsd.xpc.agent" +) + +readonly OS_NAME="$(uname -s)" +if [[ "${OS_NAME}" != "Darwin" ]]; then + printf >&2 "macOS required (\`uname -s\` was '%s')\n" \ + "${OS_NAME}" + exit 1 +fi + +readonly OS_RELEASE="$(uname -r)" +if [[ "${OS_RELEASE%%.*}" != "17" ]]; then + printf >&2 "macOS High Sierra required (\`uname -r\` was '%s')\n" \ + "${OS_RELEASE}" + exit 1 +fi + +# Quit System Preferences to prevent overrides during script execution +osascript -e 'tell application "System Preferences" to quit' + +# Ask for administrator privileges +sudo -v + +# Ensure sudo's cached credentials stay valid +while true; do + sudo -H -n /usr/bin/true + sleep 30 + if ! kill -0 "$$"; then + exit + fi +done >/dev/null 2>&1 & + +# +# General UI/UX +# + +# Set Help Viewer windows to non-floating mode +defaults write com.apple.helpviewer DevMode -bool true + +# Show remaining battery percentage in the menu bar +defaults write com.apple.menuextra.battery ShowPercent -string "YES" + +# Increase window resize speed +defaults write -g NSWindowResizeTime -float 0.001 + +# Save to disk by default +defaults write -g NSDocumentSaveNewDocumentsToCloud -bool false + +# Expand save panel by default +defaults write -g NSNavPanelExpandedStateForSaveMode -bool true +defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true + +# Expand print panel by default +defaults write -g PMPrintingExpandedStateForPrint -bool true +defaults write -g PMPrintingExpandedStateForPrint2 -bool true + +# Display ASCII control characters using caret notation in standard text views +defaults write -g NSTextShowsControlCharacters -bool true + +# Disable smart capitalization/dashes/periods/quotes for typing code +defaults write -g NSAutomaticCapitalizationEnabled -bool false +defaults write -g NSAutomaticDashSubstitutionEnabled -bool false +defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false +defaults write -g NSAutomaticQuoteSubstitutionEnabled -bool false + +# Disable resuming apps on login +defaults write -g NSQuitAlwaysKeepsWindows -bool false + +# Disable automatic termination of inactive apps +defaults write -g NSDisableAutomaticTermination -bool true + +# Set standby delay (time until hibernate after entering sleep) to 12 hours +sudo -H pmset -a standbydelay 43200 + +# Restart automatically if the computer freezes +sudo -H systemsetup -setrestartfreeze on + +# +# Keyboard +# + +# Set a stupid fast key repeat rate +defaults write -g ApplePressAndHoldEnabled -bool false +defaults write -g InitialKeyRepeat -int 25 +defaults write -g KeyRepeat -int 1 + +# +# Finder +# + +# Don't creating .DS_Store files on network or USB volumes +defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true +defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true + +# Show all filename extensions +defaults write -g AppleShowAllExtensions -bool true + +# Disable the warning when changing a file extension +defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false + +# Show the status bar +defaults write com.apple.finder ShowStatusBar -bool true + +# Show the path bar +defaults write com.apple.finder ShowPathbar -bool true + +# Show the /Volumes folder +sudo -H chflags nohidden /Volumes + +# Show the ~/Library folder +chflags nohidden "${HOME}/Library" + +# +# Dock and Mission Control +# + +# Automatically hide and show the Dock +defaults write com.apple.dock autohide -bool true + +# Speed up Mission Control animations +defaults write com.apple.dock expose-animation-duration -float 0.1 + +# Change minimize/maximize window effect to scale +defaults write com.apple.dock mineffect -string "scale" + +# Don’t automatically rearrange Spaces based on most recent use +defaults write com.apple.dock mru-spaces -bool false + +# Make Dock icons of hidden applications translucent +defaults write com.apple.dock showhidden -bool true + +# +# Activity Monitor, Disk Utility, and TextEdit +# + +# Visualize CPU usage in the Activity Monitor Dock icon +defaults write com.apple.ActivityMonitor IconType -int 5 + +# Show all processes in Activity Monitor +defaults write com.apple.ActivityMonitor ShowCategory -int 0 + +# Enable the debug menu in Disk Utility +defaults write com.apple.DiskUtility advanced-image-options -bool true +defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true + +# Use plain text mode for new TextEdit documents +defaults write com.apple.TextEdit RichText -int 0 + +# Open and save files as UTF-8 in TextEdit +defaults write com.apple.TextEdit PlainTextEncoding -int 4 +defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 + +# +# Finish +# + +# Kill affected apps +for app in "${APPS[@]}"; do + killall "${app}" >/dev/null 2>&1 +done + +# Kickstart affected agents +for agent in "${LAUNCH_AGENTS[@]}"; do + launchctl kickstart -k "gui/${UID}/${agent}" >/dev/null 2>&1 +done + +printf "Done. Some changes will require a logout/reboot to take effect.\n" diff --git a/dot/osx b/dot/osx deleted file mode 100755 index 2165f03..0000000 --- a/dot/osx +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env bash - -if [[ "$(uname -s)" != "Darwin" ]]; then - printf >&2 "This script should only be run on macOS.\n" - exit 1 -fi - -readonly DARWIN_MAJOR_VERSION="$(uname -r | sed -e 's/\..*//')" - -############################################################################### -# General UI/UX # -############################################################################### - -# Menu bar: show remaining battery percentage -defaults write com.apple.menuextra.battery ShowPercent -string "YES" - -# Display ASCII control characters using caret notation in standard text views -# Try e.g. `cd /tmp; unidecode "\x{0000}" >cc.txt; open -e cc.txt` -defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true - -# Disable Resume system-wide -defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false - -# Disable automatic termination of inactive apps -defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true - -# Set a blazingly fast keyboard repeat rate -if [[ "${DARWIN_MAJOR_VERSION}" -le "15" ]]; then - defaults write NSGlobalDomain KeyRepeat -int 0 -else - defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false - defaults write NSGlobalDomain KeyRepeat -int 1 - defaults write NSGlobalDomain InitialKeyRepeat -int 12 -fi - -# Disable smart quotes/dashes because typing code into Slack -defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false -defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false - -############################################################################### -# Screen # -############################################################################### - -# Require password 5 seconds after sleep or screen saver begins -defaults write com.apple.screensaver askForPassword -int 1 -defaults write com.apple.screensaver askForPasswordDelay -int 5 - -# Enable subpixel font rendering on non-Apple LCDs -defaults write NSGlobalDomain AppleFontSmoothing -int 2 - -############################################################################### -# Finder # -############################################################################### - -# Finder: show all filename extensions -defaults write NSGlobalDomain AppleShowAllExtensions -bool true - -# Disable the warning when changing a file extension -defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false - -# Show the ~/Library folder -chflags nohidden ~/Library - -############################################################################### -# Dock & hot corners # -############################################################################### - -# Speed up Mission Control animations -defaults write com.apple.dock expose-animation-duration -float 0.1 - -# Automatically hide and show the Dock -defaults write com.apple.dock autohide -bool true - -# Make Dock icons of hidden applications translucent -defaults write com.apple.dock showhidden -bool true - -############################################################################### -# Kill affected applications # -############################################################################### - -for process in Finder Dock SystemUIServer; do - killall "${process}" >/dev/null 2>&1 -done -echo "Done. Note that some of these changes require a logout/restart to take effect."