my_config

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2016-10-04 15:34:25 +03:00
parent 5fd9489f14
commit fd3bca11c5
6 changed files with 17 additions and 15 deletions

View File

@ -8,7 +8,7 @@ class BspwmPager < Worker
pipe.each do |line| pipe.each do |line|
monitor = line.split(":")[0] monitor = line.split(":")[0]
if @config['mod']['bspwm_pager'].has_key?("monitors") == false || @config['mod']['bspwm_pager']['monitors'].include?(monitor) if @my_config.has_key?("monitors") == false || @my_config['monitors'].include?(monitor)
self.write parse_data(line) self.write parse_data(line)
end end
end end
@ -22,8 +22,8 @@ class BspwmPager < Worker
string.split(":").each do |part| string.split(":").each do |part|
n = part[1..-1] n = part[1..-1]
if @config['mod']['bspwm_pager']['blacklist'] != nil if @my_config['blacklist'] != nil
if @config['mod']['bspwm_pager']['blacklist'].include? n if @my_config['blacklist'].include? n
next next
end end
end end
@ -36,7 +36,7 @@ class BspwmPager < Worker
when /^o.+/ when /^o.+/
out << "%{A:bspc desktop -f #{n}:} #{n} %{A}" out << "%{A:bspc desktop -f #{n}:} #{n} %{A}"
when /^f.+/ when /^f.+/
if @config['mod']['bspwm_pager']['show_empty_desktops'] if @my_config['show_empty_desktops']
out << " #{n} " out << " #{n} "
end end
when /^L.+/ when /^L.+/

View File

@ -9,7 +9,7 @@ class BspwmTaskbar < Worker
if line == "\n" if line == "\n"
self.write "" self.write ""
else else
tmpl = Template.new(@config['mod']['bspwm_taskbar']['begin'] + line.chomp + @config['mod']['bspwm_taskbar']['end']) tmpl = Template.new(@my_config['begin'] + line.chomp + @my_config['end'])
self.write tmpl.render(@config, nil) self.write tmpl.render(@config, nil)
end end
end end

View File

@ -3,7 +3,7 @@
class ModDate < Worker class ModDate < Worker
def mainloop() def mainloop()
while true do while true do
self.write Time.now.strftime(@config['mod']['date']['format']) self.write Time.now.strftime(@my_config['format'])
sleep(1) sleep(1)
end end
end end

View File

@ -6,12 +6,12 @@ class LoadAverage < Worker
file = File.open("/proc/loadavg", "r") file = File.open("/proc/loadavg", "r")
la_m = file.gets.split[0] la_m = file.gets.split[0]
if la_m.to_i > @config['mod']['load_average']['crit_value'] if la_m.to_i > @my_config['crit_value']
fg_colour = @config['mod']['load_average']['crit_colour'] fg_colour = @my_config['crit_colour']
elsif la_m.to_i > @config['mod']['load_average']['warn_value'] elsif la_m.to_i > @my_config['warn_value']
fg_colour = @config['mod']['load_average']['warn_colour'] fg_colour = @my_config['warn_colour']
else else
fg_colour = @config['mod']['load_average']['ok_colour'] fg_colour = @my_config['ok_colour']
end end
self.write "%{F#{fg_colour}}#{la_m}%{F-}" self.write "%{F#{fg_colour}}#{la_m}%{F-}"

View File

@ -13,7 +13,7 @@ class Network < Worker
end end
def network_status def network_status
hosts = @config['mod']['network']['hosts'] hosts = @my_config['hosts']
net_fail = 0 net_fail = 0
hosts.each do |h| hosts.each do |h|
@ -25,13 +25,13 @@ class Network < Worker
if net_fail == 0 if net_fail == 0
status = "ok" status = "ok"
fg_colour = @config['mod']['network']['ok_colour'] fg_colour = @my_config['ok_colour']
elsif net_fail == hosts.length elsif net_fail == hosts.length
status = "CRIT: all hosts failed!" status = "CRIT: all hosts failed!"
fg_colour = @config['mod']['network']['crit_colour'] fg_colour = @my_config['crit_colour']
else else
status = "WARN: #{net_fail} host(s) failed" status = "WARN: #{net_fail} host(s) failed"
fg_colour = @config['mod']['network']['warn_colour'] fg_colour = @my_config['warn_colour']
end end
return "%{F#{fg_colour}}#{status}%{F-}" return "%{F#{fg_colour}}#{status}%{F-}"

View File

@ -8,6 +8,8 @@ class Worker
@config = config @config = config
@name = name @name = name
@pipe_in = pipe @pipe_in = pipe
@my_config = config["mod"][name]
end end
def run() def run()