-
Notifications
You must be signed in to change notification settings - Fork 2
/
rules.rb
70 lines (56 loc) · 1.77 KB
/
rules.rb
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
Maid.rules do
RUN_TIME = Time.now
DAY_SECONDS = 60 * 60 * 24
WEEK = DAY_SECONDS * 7
ONE_WEEK_AGO = (RUN_TIME - WEEK)
TWO_WEEKS_AGO = (RUN_TIME - WEEK * 2)
THREE_MONTHS_AGO = (RUN_TIME - (DAY_SECONDS * 93))
rule 'Update yourself' do
`homesick pull`
`homesick symlink`
end
# custom rules based on known machine names
case %x/hostname -s/.chomp
when 'jeffrey-tripletts-macbook-pro'
when 'Jeffs-Mac-mini'
when 'Jeff-Tripletts-iMac'
when 'TV'
end
case %x/uname -s/.chomp
when 'Darwin'
rule '/Library/Caches/Homebrew/' do
dir('/Library/Caches/Homebrew/*.tar.*').each do |path|
trash path if File.mtime(path) > THREE_MONTHS_AGO
end
dir('/Library/Caches/Homebrew/*.tgz').each do |path|
trash path if File.mtime(path) > THREE_MONTHS_AGO
end
dir('/Library/Caches/Homebrew/*.tbz').each do |path|
trash path if File.mtime(path) > THREE_MONTHS_AGO
end
end
rule '~/Library/Caches' do
dir('~/Library/Caches/Google/Chrome/Default/Cache/*').each do |path|
trash path if File.mtime(path) > THREE_MONTHS_AGO
end
end
rule 'Collect downloaded videos to watch later' do
move where_content_type(dir('~/Downloads/*'), 'video'), '~/Movies/'
dir('~/Downloads/*.{mkv,mp4,avi}').each do |path|
move(path, '~/Movies/')
end
end
rule 'Cleanup Downloads + Desktop' do
["~/Downloads", "~/Desktop"].each do |junk_drawer|
dir("#{junk_drawer}/*").each do |path|
if 2.week.since?(accessed_at(path))
trash(path)
end
end
end
end
end
rule 'Update crontab' do
`whenever --update-crontab -f ~/.maid/schedule.rb`
end
end