-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathoverkill.rb
41 lines (34 loc) · 844 Bytes
/
overkill.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
module Overkill
class Monitor
def run
output = `ps aux | grep -E "#{apps_to_kill.keys.join('|')}"`.split("\n")
output.each do |current|
next if blacklist.any? { |a| current.include?(a) }
apps_to_kill.each do |app_name, emoji|
next unless current.include?("/Applications/#{app_name}.app/Contents/MacOS/#{app_name}")
puts "#{app_name} launched itself, killing the process now... 💥 #{emoji}"
`killall #{app_name}`
end
end
sleep 0.1
end
def apps_to_kill
apps = {
"iTunes" => "🎵"
}
apps["Photos"] = "🖼" if ENV["KILL_PHOTOS"]
apps
end
def blacklist
[
"iTunesHelper"
]
end
def self.start
loop do
self.new.run
end
end
end
end
Overkill::Monitor.start