-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
355 lines (300 loc) · 11.6 KB
/
Rakefile
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
$library_dir = File.join(Dir.home, "Library")
$scripts_dir = File.join($library_dir, "Scripts")
$applications_dir = File.join($scripts_dir, "Applications")
$dir_mask = 0700
task :default => [:install]
task :make_scripts_dir do
unless File.directory? $scripts_dir
Dir.mkdir($scripts_dir, $dir_mask)
system("chmod +a \"everyone deny delete\" #{$scripts_dir}")
end
unless File.directory? $applications_dir
Dir.mkdir($applications_dir, $dir_mask)
end
end
task :make_subdirectory, [:dest_dir, :dir_names] => [:make_scripts_dir] do | t, args |
dest_dir = args[:dest_dir]
dir_names = args[:dir_names]
dir_names.each do | dir_name |
destination = File.join("#{dest_dir}", "#{dir_name}")
unless File.directory? destination
Dir.mkdir(destination, $dir_mask)
end
end
end
desc "Make application folders for scripts"
task :make_application_dirs do
dir_names = Array.new
dir_names.push("Carbon Copy Cloner")
dir_names.push("Finder")
dir_names.push("GarageBand")
dir_names.push("OmniFocus")
dir_names.push("Photos")
dir_names.push("Safari")
dir_names.push("Spark")
# dir_names.push("SuperDuper")
# dir_names.push("Yojimbo")
Rake::Task["make_subdirectory"].invoke($applications_dir, dir_names)
dir_names = Array.new
dir_names.push("Folder Action Scripts")
Rake::Task["make_subdirectory"].reenable
Rake::Task["make_subdirectory"].invoke($scripts_dir, dir_names)
end
task :compile, :src, :out do |t, args|
src = args[:src]
out = args[:out]
puts "osacompile -o \"#{out}\" \"#{src}\""
system("osacompile -o \"#{out}\" \"#{src}\"")
end
desc "Installs all scripts"
task :install do
# Requires Carbon Copy Cloner
Rake::Task["backup_audio_recordings"].invoke
# Requires Finder
Rake::Task["close_all_finder_windows"].invoke
Rake::Task["eject_all_disks"].invoke
Rake::Task["km_count_finder_items"].invoke
Rake::Task["make_comic_book_archive"].invoke
Rake::Task["open_home_folders"].invoke
Rake::Task["show_screen_resolution"].invoke
# Requires GarageBand
Rake::Task["set_garageband_project_name"].invoke
# Requires Photos
Rake::Task["export_images"].invoke
# Requires Nitro PDF Pro (formerly PDFpen Pro)
Rake::Task["ocr_pdf_documents_folder_action"].invoke
Rake::Task["ocr_pdf_documents_hazel"].invoke
# Requires SystemEvents and Activity Monitor
Rake::Task["open_activity_monitor"].invoke
# Requires Google Chrome and Safari
Rake::Task["open_in_google_chrome"].invoke
# Requires Safari
Rake::Task["save_safari_window_positions"].invoke
# Requires Spark
Rake::Task["search_spark_mailbox"].invoke
Rake::Task["switch_to_normal_mode"].invoke
Rake::Task["switch_to_quiet_mode"].invoke
# Requires Yojimbo
# Rake::Task["backup_boot_drive"].invoke
# Rake::Task["drop_items_to_yojimbo_folder_action"].invoke
# Rake::Task["export_images_to_yojimbo"].invoke
# Rake::Task["make_web_archive_in_yojimbo"].invoke
end
# com.bombich.ccc6.task.open://A241E37B-B1BE-4261-B814-38EEADAF036A
desc "Backup Audio Recordings"
task :backup_audio_recordings => :make_application_dirs do
src = "backup_audio_recordings.applescript"
out = "Backup Audio Recordings.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Carbon Copy Cloner")
FileUtils.mv(out, destination)
end
desc "Backup Boot Drive"
task :backup_boot_drive => :make_application_dirs do
src = "backup_boot_drive.applescript"
out = "Backup Boot Drive.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "SuperDuper")
FileUtils.mv(out, destination)
end
desc "Close All Finder Windows"
task :close_all_finder_windows => :make_application_dirs do
src = "close_all_finder_windows.applescript"
out = "Close All Finder Windows.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
# This script can be called from any application
FileUtils.mv(out, $scripts_dir)
end
desc "Drop Items to Yojimbo Folder Action"
task :drop_items_to_yojimbo_folder_action => :make_application_dirs do
src = "drop_items_to_yojimbo_folder_action.applescript"
out = "Drop Items to Yojimbo Folder Action.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($scripts_dir, "Folder Action Scripts")
FileUtils.mv(out, destination)
end
desc "Eject All Disks"
task :eject_all_disks => :make_application_dirs do
src = "eject_all_disks.applescript"
out = "Eject All Disks.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "Export Images to Yojimbo"
task :export_images_to_yojimbo => :make_application_dirs do
src = "export_images_to_yojimbo.applescript"
out = "Export Images to Yojimbo.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Photos")
FileUtils.mv(out, destination)
end
desc "Export Images"
task :export_images => :make_application_dirs do
src = "export_images.applescript"
out = "Export Images.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Photos")
FileUtils.mv(out, destination)
end
desc "KM Count Finder Items"
task :km_count_finder_items => :make_application_dirs do
src = "km_count_finder_items.applescript"
out = "KM Count Finder Items.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Finder")
FileUtils.mv(out, destination)
end
desc "Make Comic Book Archive"
task :make_comic_book_archive => :make_application_dirs do
src = "make_comic_book_archive.applescript"
out = "Make Comic Book Archive.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Finder")
FileUtils.mv(out, destination)
end
desc "Make Web Archive in Yojimbo"
task :make_web_archive_in_yojimbo => :make_application_dirs do
src = "make_web_archive_in_yojimbo.applescript"
out = "Make Web Archive in Yojimbo.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Safari")
FileUtils.mv(out, destination)
end
desc "Open Activity Monitor"
task :open_activity_monitor => :make_application_dirs do
src = "open_activity_monitor.applescript"
out = "Open Activity Monitor.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "OCR PDF Documents Folder Action"
task :ocr_pdf_documents_folder_action => :make_application_dirs do
src = "ocr_pdf_documents_folder_action.applescript"
out = "OCR PDF Documents Folder Action.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($scripts_dir, "Folder Action Scripts")
FileUtils.mv(out, destination)
end
desc "OCR PDF Documents Hazel"
task :ocr_pdf_documents_hazel => :make_application_dirs do
src = "ocr_pdf_documents_hazel.applescript"
out = "OCR PDF Documents Hazel.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($scripts_dir, "Folder Action Scripts")
FileUtils.mv(out, destination)
end
desc "Open Activity Monitor - Energy"
task :open_activity_monitor => :make_application_dirs do
src = "open_activity_monitor.applescript"
out = "Open Activity Monitor.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "Open Home Folders"
task :open_home_folders => :make_application_dirs do
src = "open_home_folders.applescript"
out = "Open Home Folders.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "Open in Google Chrome"
task :open_in_google_chrome => :make_application_dirs do
src = "open_in_google_chrome.applescript"
out = "Open in Google Chrome.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Safari")
FileUtils.mv(out, destination)
end
desc "Save Safari Window Positions"
task :save_safari_window_positions => :make_application_dirs do
src = "save_safari_window_pos.applescript"
out = "Save Safari Window Positions.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Safari")
FileUtils.mv(out, destination)
end
desc "Search Spark Mailbox"
task :search_spark_mailbox => :make_application_dirs do
src = "search_spark_mailbox.applescript"
out = "Search Spark Mailbox.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "Spark")
FileUtils.mv(out, destination)
end
desc "Set GarageBand Project Name"
task :set_garageband_project_name => :make_application_dirs do
src = "set_garageband_project_name.applescript"
out = "Set GarageBand Project Name.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "GarageBand")
FileUtils.mv(out, destination)
end
desc "Show Screen Resolution"
task :show_screen_resolution => :make_application_dirs do
src = "show_screen_resolution.applescript"
out = "Show Screen Resolution.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "Switch to Normal Mode"
task :switch_to_normal_mode => :make_application_dirs do
src = "switch_to_normal_mode.applescript"
out = "Switch to Normal Mode.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "Switch to Quiet Mode"
task :switch_to_quiet_mode => :make_application_dirs do
src = "switch_to_quiet_mode.applescript"
out = "Switch to Quiet Mode.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
FileUtils.mv(out, $scripts_dir)
end
desc "OmniFocus - Open Inbox perspective"
task :omnifocus_open_inbox => :make_application_dirs do
src = "omnifocus_open_inbox.applescript"
out = "OmniFocus - Open Inbox.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "OmniFocus")
FileUtils.mv(out, destination)
end
desc "OmniFocus - Open Forecast perspective"
task :omnifocus_open_forecast => :make_application_dirs do
src = "omnifocus_open_forecast.applescript"
out = "OmniFocus - Open Forecast.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "OmniFocus")
FileUtils.mv(out, destination)
end
desc "OmniFocus - Open Projects perspective"
task :omnifocus_open_projects => :make_application_dirs do
src = "omnifocus_open_projects.applescript"
out = "OmniFocus - Open Projects.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "OmniFocus")
FileUtils.mv(out, destination)
end
desc "OmniFocus - Open Flagged perspective"
task :omnifocus_open_flagged => :make_application_dirs do
src = "omnifocus_open_flagged.applescript"
out = "OmniFocus - Open Flagged.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "OmniFocus")
FileUtils.mv(out, destination)
end
desc "OmniFocus - Open Review perspective"
task :omnifocus_open_review => :make_application_dirs do
src = "omnifocus_open_review.applescript"
out = "OmniFocus - Open Review.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "OmniFocus")
FileUtils.mv(out, destination)
end
desc "OmniFocus - Open Tags perspective"
task :omnifocus_open_tags => :make_application_dirs do
src = "omnifocus_open_tags.applescript"
out = "OmniFocus - Open Tags.scpt"
Rake::Task["compile"].execute(:src => src, :out => out)
destination = File.join($applications_dir, "OmniFocus")
FileUtils.mv(out, destination)
end