new module and some tweaks

This commit is contained in:
Jack L. Frost 2016-10-21 17:56:25 +03:00
parent c772ed8ce3
commit 8332f8a49f
2 changed files with 32 additions and 16 deletions

17
mod/battery Normal file
View File

@ -0,0 +1,17 @@
# vim: ft=ruby
class Battery < Worker
require 'open3'
def mainloop()
while true do
Open3.popen2("acpi") {|i,o,t|
self.write(o.gets.split[3])
}
sleep(10)
end
end
end
Modules.add("battery", "Battery")

View File

@ -16,13 +16,9 @@ class Network < Worker
hosts = @my_config['hosts'] hosts = @my_config['hosts']
net_fail = 0 net_fail = 0
i,o,t = Open3.popen2("fping", *hosts) Open3.popen2("fping", *hosts) {|i,o,t|
t.join
net_ok = o.each_line.count net_ok = o.each_line.count
i.close; o.close
if net_ok == hosts.count if net_ok == hosts.count
status = "ok" status = "ok"
fg_colour = @my_config['ok_colour'] fg_colour = @my_config['ok_colour']
@ -34,7 +30,10 @@ class Network < Worker
fg_colour = @my_config['warn_colour'] fg_colour = @my_config['warn_colour']
end end
return "%{F#{fg_colour}}#{status}%{F-}" @rstr = "%{F#{fg_colour}}#{status}%{F-}"
}
return @rstr
end end
end end