diff --git a/mod/bspwm_taskbar b/mod/bspwm_taskbar index 4b30192..5f936ae 100644 --- a/mod/bspwm_taskbar +++ b/mod/bspwm_taskbar @@ -9,7 +9,8 @@ class BspwmTaskbar < Worker if line == "\n" self.write "" else - self.write @config['mod']['bspwm_taskbar']['begin'].erb + line.chomp + @config['mod']['bspwm_taskbar']['end'].erb + "\n" + tmpl = Template.new(@config['mod']['bspwm_taskbar']['begin'] + line.chomp + @config['mod']['bspwm_taskbar']['end']) + self.write tmpl.render(@config, nil) end end end diff --git a/moltenbar b/moltenbar index 02e98e8..0c59369 100755 --- a/moltenbar +++ b/moltenbar @@ -79,6 +79,19 @@ module Modules end end +class Template + def initialize(template) + @template = template + end + + def render(config, data) + @config = config + @panel_data = data + + return ERB.new(@template).result(binding) + end +end + # Kill the workers. def cleanup(workers) for w in workers do @@ -164,6 +177,7 @@ IO.popen(lemonbar_cmd, "w+") do |pipe_lb| mod_name, data = line.chomp.split("\0") panel_data[mod_name] = data - pipe_lb.puts config['format'].erb + t = Template.new(config['format']) + pipe_lb.puts t.render(config, panel_data) end end