-
Notifications
You must be signed in to change notification settings - Fork 0
/
set-macos-defaults
executable file
·154 lines (110 loc) · 4.64 KB
/
set-macos-defaults
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
set -e
sudo -v
# Close any open System Settings panes
osascript -e 'tell application "System Settings" to quit'
# SECTION: Dock
# Automatically hide dock
defaults write com.apple.dock autohide -bool true
# Disable show recent apps in dock
defaults write com.apple.dock show-recents -bool false
# Disable automatically rearrange spaces
defaults write com.apple.dock mru-spaces -bool false
# SECTION: Finder
# Avoid 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
# Open new Finder window in home directory
defaults write com.apple.finder NewWindowTargetPath -string "file://$HOME"
# Hide recent tags
defaults write com.apple.finder ShowRecentTags -bool false
# Set default view style to column view
defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
# Desktop view settings
FINDER_PLIST="$HOME/Library/Preferences/com.apple.finder.plist"
plutil -replace DesktopViewSettings.GroupBy -string "None" "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.arrangeBy -string "kind" "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.gridSpacing -integer 48 "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.iconSize -integer 48 "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.labelOnBottom -integer 0 "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.showIconPreview -integer 1 "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.showItemInfo -integer 0 "$FINDER_PLIST"
plutil -replace DesktopViewSettings.IconViewSettings.textSize -integer 12 "$FINDER_PLIST"
unset FINDER_PLIST
# SECTION: Input Devices
# Disable press-and-hold for keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
# Set a fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 20
# Trackpad: enable tap to click
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 0
# Remap caps lock to escape
LAUNCH_AGENTS_DIR="$HOME/Library/LaunchAgents"
mkdir -p "$LAUNCH_AGENTS_DIR"
cat > "$LAUNCH_AGENTS_DIR/com.ryantoddgarza.CapslockEsc.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ryantoddgarza.CapslockEsc</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/hidutil</string>
<string>property</string>
<string>--set</string>
<string>{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOF
unset LAUNCH_AGENTS_DIR
# SECTION: Network
# Uncomment to use Cloudflare DNS
# sudo networksetup -setdnsservers Wi-Fi \
# 1.1.1.1 \
# 1.0.0.1 \
# 2606:4700:4700::1111 \
# 2606:4700:4700::1001
# Section: Power Management
# Restore defaults: all power management settings should be made in this script
sudo pmset restoredefaults > /dev/null
# Sleep the display after 15 minutes while charging
sudo pmset -c displaysleep 15
# Disable machine sleep while charging
sudo pmset -c sleep 0
# Sleep the display after 2 minutes on battery
sudo pmset -b displaysleep 2
# Set machine sleep to 5 minutes on battery
sudo pmset -b sleep 5
# Set standby delay to 24 hours (default is 1 hour)
sudo pmset -a standbydelay 86400
# Disable screen dim on battery
sudo pmset -b lessbright 0
# SECTION: Accessibility
# Reduce transparency
sudo defaults write com.apple.universalaccess reduceTransparency -bool true
# SECTION: Screencapture
# Set screencapture directory
SCREENCAPTURE_DIR="$HOME/Pictures/Screencapture"
mkdir -p "$SCREENCAPTURE_DIR"
# Save screencapture to specified directory
defaults write com.apple.screencapture location -string "$SCREENCAPTURE_DIR"
# Save screencapture as png
defaults write com.apple.screencapture type -string "png"
# Remove default timestamp
defaults write com.apple.screencapture include-date -bool false
# Set screencapture filename
defaults write com.apple.screencapture name -string "$(hostname)-$(date +"%Y%m%dT%H%M%S")"
# Disable drop shadow
defaults write com.apple.screencapture disable-shadow -bool true
unset SCREENCAPTURE_DIR
# SECTION: Kill affected applications
killall Dock
killall Finder
killall cfprefsd