-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_dock.sh
More file actions
executable file
·191 lines (151 loc) · 7.77 KB
/
setup_dock.sh
File metadata and controls
executable file
·191 lines (151 loc) · 7.77 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env bash
# ========================================
# macOS Dock Configuration Script
# ========================================
# Configures dock position, behavior, and app layout with
# conditional app addition (only adds apps that are installed).
#
# Usage: ./setup_dock.sh
#
# Features:
# - Idempotent: safe to run multiple times
# - Conditional: only adds installed apps
# - Grouped: uses small spacers for visual organization
#set -e
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# ═══════════════════════════════════════════════════════════════
# Helper Functions
# ═══════════════════════════════════════════════════════════════
print_status() {
local status=$1
local message=$2
case $status in
"ok") echo -e " ${GREEN}✓${NC} $message" ;;
"skip") echo -e " ${YELLOW}○${NC} $message ${YELLOW}(not installed)${NC}" ;;
"add") echo -e " ${BLUE}+${NC} $message" ;;
"spacer") echo -e " ${BLUE}│${NC} $message" ;;
esac
}
# Add app to dock if it exists
# Usage: add_app "/path/to/App.app" "App Name"
add_app() {
local app_path="$1"
local app_name="$2"
if [[ -e "$app_path" ]]; then
dockutil --add "$app_path" --no-restart &>/dev/null
print_status "add" "$app_name"
return 0
else
print_status "skip" "$app_name"
return 1
fi
}
# Add small spacer (half-width)
add_spacer() {
local group_name="${1:-}"
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="small-spacer-tile";}'
if [[ -n "$group_name" ]]; then
print_status "spacer" "── $group_name ──"
fi
}
# ═══════════════════════════════════════════════════════════════
# Dock Preferences
# ═══════════════════════════════════════════════════════════════
configure_dock_preferences() {
echo -e "\n${BLUE}Configuring dock preferences...${NC}"
# Position: left side of screen
defaults write com.apple.dock orientation -string left
# Size and magnification
defaults write com.apple.dock tilesize -int 48
defaults write com.apple.dock largesize -int 48
defaults write com.apple.dock magnification -bool false
# Minimize effect
defaults write com.apple.dock mineffect -string scale
# Minimize to application icon
defaults write com.apple.dock minimize-to-application -bool true
# Don't rearrange spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# Don't show recent/suggested apps
defaults write com.apple.dock show-recents -bool false
# Show indicator dots for open applications
defaults write com.apple.dock show-process-indicators -bool true
print_status "ok" "Dock preferences configured"
}
# ═══════════════════════════════════════════════════════════════
# Dock App Layout
# ═══════════════════════════════════════════════════════════════
configure_dock_apps() {
echo -e "\n${BLUE}Configuring dock apps...${NC}"
# Clear existing dock items
dockutil --remove all --no-restart &>/dev/null
print_status "ok" "Cleared existing dock items"
echo ""
# ────────────────────────────────────────────────────────────
# Group 1: System & Utilities
# ────────────────────────────────────────────────────────────
add_app "/System/Applications/Apps.app" "Apps"
add_app "/System/Applications/System Settings.app" "System Settings"
add_spacer "System Utilities"
add_app "/Applications/iStatistica Pro.app" "iStatistica Pro"
# Browser: Chrome on work mac (zoe), Safari elsewhere
if [[ "$(hostname -s)" == "zoe" ]]; then
add_app "/Applications/Google Chrome.app" "Chrome" ||
add_app "/Applications/Helium.app" "Helium" ||
add_app "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app" "Safari"
else
add_app "/Applications/Helium.app" "Helium" ||
add_app "/System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app" "Safari" ||
add_app "/Applications/Safari.app" "Safari" ||
add_app "/Applications/Google Chrome.app" "Chrome"
fi
add_app "/System/Applications/Music.app" "Music"
add_app "/Applications/1Password.app" "1Password"
add_spacer "Productivity"
# ────────────────────────────────────────────────────────────
# Group 3: Media & Productivity
# ────────────────────────────────────────────────────────────
if [[ "$(hostname -s)" == "zoe" ]]; then
add_app "/Applications/Slack.app" "Slack"
add_app "$HOME/Applications/Chrome Apps.localized/Google Calendar.app" "Calendar"
add_app "$HOME/Applications/Chrome Apps.localized/Google Meet.app" "Meet"
else
add_app "/Applications/Telegram.app" "Telegram"
add_app "/System/Applications/Calendar.app" "Calendar"
fi
add_app "/Applications/Obsidian.app" "Obsidian"
add_spacer "Development"
# ────────────────────────────────────────────────────────────
# Group 4: Development Tools
# ────────────────────────────────────────────────────────────
add_app "/Applications/cmux.app" "cmux" ||
add_app "/Applications/Ghostty.app" "Ghostty" ||
add_app "/Applications/iTerm.app" "iTerm" ||
add_app "/System/Applications/Utilities/Terminal.app" "Terminal"
add_app "/Applications/Cursor.app" "Cursor" ||
add_app "/Applications/Visual Studio Code.app" "VSCode"
add_spacer ""
}
# ═══════════════════════════════════════════════════════════════
# Main
# ═══════════════════════════════════════════════════════════════
main() {
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE} Dock Configuration${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
# Check for dockutil
if ! command -v dockutil &>/dev/null; then
echo -e " ${YELLOW}dockutil not found. Install with: brew install dockutil${NC}"
exit 1
fi
configure_dock_preferences
configure_dock_apps
# Restart dock to apply changes
echo -e "\n${BLUE}Restarting Dock...${NC}"
killall Dock
echo -e "\n${GREEN}✓ Dock configured successfully${NC}\n"
}
main "$@"