Permalink
Browse files
Add support for Photos app with custom emoji support
- Loading branch information...
Showing
with
27 additions
and
9 deletions.
-
+27
โ9
overkill.rb
|
|
@@ -1,21 +1,39 @@ |
|
|
module Overkill
|
|
|
class Monitor
|
|
|
def run
|
|
|
- loop do
|
|
|
- output = `ps aux | grep iTunes`.split("\n")
|
|
|
- output.each do |current|
|
|
|
- next if current.include?("iTunesHelper")
|
|
|
- next unless current.include?("/Applications/iTunes.app/Contents/MacOS/iTunes")
|
|
|
+ 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 "iTunes launched itself, killing the process now... ๐ฅ๐ต"
|
|
|
- `killall iTunes`
|
|
|
+ puts "#{app_name} launched itself, killing the process now... ๐ฅ #{emoji}"
|
|
|
+ `killall #{app_name}`
|
|
|
end
|
|
|
- sleep 0.1
|
|
|
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
|
|
|
- self.new.run
|
|
|
+ loop do
|
|
|
+ self.new.run
|
|
|
+ end
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
|
0 comments on commit
2393677