The i3 FAQ has migrated to https://www.reddit.com/r/i3wm/. All content here is read-only.
Ask Your Question
1

i3bar updated only after `status_command` process exits

asked 2014-04-15 11:49:19 +0000

simao gravatar image

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

edit retag flag offensive close merge delete

Comments

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.

Adaephon gravatar imageAdaephon ( 2014-04-15 13:17:29 +0000 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-04-15 17:18:53 +0000

badboy_ gravatar image

Try $stdout.flush to flush the output (as Adaephon said in the comment already)

edit flag offensive delete link more

Comments

Yeah I tried that but still nothing changes..

simao gravatar imagesimao ( 2014-04-16 08:33:53 +0000 )edit

I was doing something wrong before, I tried this again and it works. Thanks

simao gravatar imagesimao ( 2014-04-16 13:42:18 +0000 )edit

Question Tools

Stats

Asked: 2014-04-15 11:49:19 +0000

Seen: 260 times

Last updated: Apr 15 '14