-
-
Save phromo/6a41be2bc4d716751eee2eb29856d4bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sys/proctable' | |
require 'rufus-scheduler' | |
include Sys | |
def is_org_running() | |
ProcTable.ps do |p| | |
return true if p.comm.include? "Xorg" | |
end | |
return false | |
end | |
def aw_pids() | |
pids = [] | |
ProcTable.ps do |p| | |
next unless p.comm.include? "aw-watcher" | |
pids << p.pid | |
end | |
return pids | |
end | |
def main_awkiller() | |
return [] if is_org_running() | |
procs_kill = aw_pids() | |
procs_kill.each do |pid| | |
Process.kill("HUP", pid) | |
end | |
return procs_kill | |
end | |
scheduler = Rufus::Scheduler.new | |
scheduler.every '1m' do | |
main_awkiller().each do |pid| | |
puts "killed pid #{pid}" | |
end | |
end | |
puts "awkiller.rb starting main loop, checking every 1m" | |
main_awkiller().each do |pid| | |
puts "killed pid #{pid}" | |
end | |
scheduler.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment