i3bar updated only after `status_command` process exits
Hello,
I am using the following ruby script to parse the status output by conky and produce a json string:
#!/usr/bin/ruby
require 'json'
puts '{"version":1}'
puts '['
puts '[],'
IO.popen("conky -c $HOME/.conkyrc_json").each do |line|
conky = JSON.parse(line)
out = "["
out << "{\"full_text\": \"#{conky['network']}\", \"color\": \"\#FFFFFF\"},"
out << "],"
puts out
end
If I simply run this script, i3bar doesn't render any text, it just shows tray icons.
However, if in the end of the loop I add a exit
statement, i3bar shows the text produced in the last loop, but since the ruby wrapper then exits, the text in i3bar is never updated.
Do I need to send an extra signal to i3bar? How can I force i3bar to update without exiting my wrapper script?
Thank you
I'm not sure how it is done in ruby, but you may need to either explicitly flush stdout after `puts` or switch on line-based buffering. Otherwise the output of your command will only be passed to i3bar once the output buffer (usually around 8kb) is full.