-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathdock
executable file
·188 lines (175 loc) · 5.19 KB
/
dock
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
#!/usr/bin/env bash
help(){
cat<<__EOF__
usage: m dock [ showdelay | autohide | magnification | position | addblankspace | additem | addrecentitems | prune | help ]
Examples:
m dock showdelay x.x # Changes how long the Dock takes to show up when auto-hide is enabled
m dock autohide YES # Enable Dock's auto hide feature
m dock autohide NO # Disable Dock's auto hide feature
m dock autohidedelay x.x # Changes how long it takes to detect you want to show up the dock
m dock magnification YES # Turn magnification on
m dock magnification NO # Turn magnification off
m dock position BOTTOM # Change Dock's position to the bottom of the screen
m dock position LEFT # Change Dock's position to the left of the screen
m dock position RIGHT # Change Dock's position to the right of the screen
m dock addblankspace # Add a blank space (separator) to the Dock
m dock additem PATH # Add an item to the Dock, e.g. /Applications/Safari.app
m dock addrecentitems # Add a stack containg your recent items to the Dock
# (You can change the stack's type by right clicking on it)
m dock prune # remove all items from dock
__EOF__
}
show_delay(){
case $1 in
[0-9][.][0-9])
echo "New Auto-Hide time: "$1
defaults write com.apple.dock autohide-time-modifier -float $1
;;
[0-9])
echo "New Auto-Hide time: "$1
defaults write com.apple.dock autohide-time-modifier -int $1
;;
*)
echo "Current Auto-Hide time: $(defaults read com.apple.dock autohide-time-modifier 2>/dev/null)"
exit 0
;;
esac
killall Dock
}
auto_hide(){
case $1 in
[yY][eE][sS])
echo "Auto Hide: YES"
defaults write com.apple.dock autohide -boolean YES
;;
[nN][oO])
echo "Auto Hide: No"
defaults write com.apple.dock autohide -boolean NO
;;
*)
echo "Auto Hide: $(defaults read com.apple.dock autohide)"
exit 0
;;
esac
killall Dock
}
autohide_delay(){
case $1 in
[0-9][.][0-9])
echo "New Auto-Hide delay time: "$1
defaults write com.apple.dock autohide-delay -float $1
;;
[0-9])
echo "New Auto-Hide delay time: "$1
defaults write com.apple.dock autohide-delay -int $1
;;
*)
echo "Current Auto-Hide delay time: $(defaults read com.apple.dock autohide-delay 2>/dev/null)"
exit 0
;;
esac
killall Dock
}
magnify(){
case $1 in
[yY][eE][sS])
echo "Magnification: YES"
defaults write com.apple.dock magnification -boolean YES
;;
[nN][oO])
echo "Magnification: NO"
defaults write com.apple.dock magnification -boolean NO
;;
*)
echo "Magnification: $(defaults read com.apple.dock magnification)"
exit 0
;;
esac
killall Dock
}
dock_position(){
case $1 in
[bB][oO][tT][tT][oO][mM])
echo "Dock Position: BOTTOM"
defaults write com.apple.dock orientation bottom
;;
[lL][eE][fF][tT])
echo "Dock Position: LEFT"
defaults write com.apple.dock orientation left
;;
[rR][iI][gG][hH][tT])
echo "Dock Position: RIGHT"
defaults write com.apple.dock orientation right
;;
*)
echo "Position: $(defaults read com.apple.dock orientation)"
exit 0
;;
esac
killall Dock
}
add_blank_space(){
echo "New blank space added to the Dock"
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
}
add_item(){
[ -z "$1" ] && help && exit 1
echo "Item added to the Dock: $1"
defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>$1</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
killall Dock
}
add_recent_items(){
echo "Add recent items stack"
defaults write com.apple.dock persistent-others -array-add '{"tile-data" = {"list-type" = 1;}; "tile-type" = "recents-tile";}';
killall Dock
}
prune(){
echo "remove all items from stack"
defaults write com.apple.dock persistent-apps '()'
killall Dock
}
case $1 in
help)
help
;;
showdelay)
shift
show_delay $@
;;
autohide)
shift
auto_hide $@
;;
autohidedelay)
shift
autohide_delay $@
;;
magnification)
shift
magnify $@
;;
position)
shift
dock_position $@
;;
addblankspace)
shift
add_blank_space
;;
additem)
shift
add_item $@
;;
addrecentitems)
shift
add_recent_items
;;
prune)
shift
prune
;;
*)
help
;;
esac