From 8811476f9f8860fd460a12f1a8fd75e4109cf278 Mon Sep 17 00:00:00 2001 From: fbt Date: Thu, 29 Sep 2016 14:12:38 +0300 Subject: [PATCH] run commands that lemonbar outputs --- moltenbar | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/moltenbar b/moltenbar index 38e03a3..02e98e8 100755 --- a/moltenbar +++ b/moltenbar @@ -48,6 +48,19 @@ class Worker end end +class DoSystem < Worker + def initialize(name, pipe) + @name = name + @pipe = pipe + end + + def mainloop() + @pipe.each do |cmd| + system(cmd) + end + end +end + class ::String def erb return ERB.new(self).result @@ -143,11 +156,9 @@ puts "Launching lemonbar as: " + lemonbar_cmd.join(" ") IO.popen(lemonbar_cmd, "w+") do |pipe_lb| pipe_lb.sync = true - fork do - pipe_lb.each do |line| - system(line) - end - end + sys = DoSystem.new("system", pipe_lb) + workers << sys + sys.run() pipe_r.each do |line| mod_name, data = line.chomp.split("\0")