changeset 37:a761f06dbaa8

Add Maid rules
author zegervdv <zegervdv@me.com>
date Tue, 15 Apr 2014 17:05:15 +0200
parents 01da40867300
children 8f9bdb6cedf3
files maid/com.github.maid.plist maid/general.rb
diffstat 2 files changed, 63 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/maid/com.github.maid.plist	Tue Apr 15 17:05:15 2014 +0200
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+  <key>Label</key>
+  <string>com.github.maid</string>
+  <key>StartCalendarInterval</key>
+  <array>
+    <dict>
+      <key>Hour</key>
+      <integer>12</integer>
+      <key>Day</key>
+      <integer>1</integer>
+    </dict>
+    <dict>
+      <key>Hour</key>
+      <integer>12</integer>
+      <key>Day</key>
+      <integer>14</integer>
+    </dict>
+  </array>
+  <key>ProgramArguments</key>
+  <array>
+    <string>/Users/zegervdv/.rbenv/shims/maid</string>
+    <string>clean</string>
+    <string>-r</string>
+    <string>/Users/zegervdv/.maid/general.rb</string>
+  </array>
+  <key>ServiceDescription</key>
+  <string>Maid</string>
+</dict>
+</plist>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/maid/general.rb	Tue Apr 15 17:05:15 2014 +0200
@@ -0,0 +1,31 @@
+Maid.rules do
+  rule 'Remove old TV-show downloads' do
+    dir('~/Downloads/**/*.mkv').each do |mkv|
+      trash(mkv) if 2.weeks.since?(accessed_at(mkv))
+    end
+  end
+
+  rule 'Remove old converted TV-shows' do
+    trash(dir('~/Downloads/**/*.mp4'))
+    trash(dir('~/Downloads/**/*.m4v'))
+  end
+
+  rule 'Remove old apps' do
+    trash(dir('~/Downloads/*.dmg'))
+    trash(dir('~/Downloads/*.pkg'))
+    trash(dir('~/Downloads/*.zip'))
+    trash(dir('~/Downloads/*.iso'))
+    trash(dir('~/Downloads/*.tar'))
+    trash(dir('~/Downloads/*.tar.*'))
+  end
+
+  rule 'Remove empty folders' do
+    trash(dir('~/Downloads/**/*').select { |path| File.directory?(path) && File.stat(path).size < 1.megabyte })
+  end
+
+  rule 'Remove old files' do
+    dir('~/Downloads/**/*').each do |file|
+      trash(file) if 4.weeks.since?(accessed_at(file))
+    end
+  end
+end