I want the output of

stdbuf -i0 -o0 -e0 jack_cpu_load | sed -n 's/[A-Za-z]*//g;s/ //g;s/.\{4\}$//;9,$p'

to be displayed in Conky but, I suspect, Conky is starting the script with every refresh and the script is too slow producing an output for anything to show.

Or, maybe it's something else entirely.

I used ${execp /path/to/script.sh}

Is there a way to let the script run and for Conky to sample the output. Provided my theory is correct. shrugs

Edit: I'm working on sending the output to a file then having Conky read that, but I'm having a hard time getting it to overwrite the file.

The closest I've gotten so far is, stdbuf -i0 -o0 -e0 script.sh > file.log but that just keeps appending the output to the file until I stop and start it again.

  • maybe look into the mkfifo command...
    – mikeserv
    Apr 3 '14 at 8:41

You should say that this is related to Pipe output of jack_cpu_load through sed

So you wish to extract the float values from this output

jack DSP load 0.163633
jack DSP load 0.159914
jack DSP load 0.159449
jack DSP load 0.164087
jack DSP load 0.159971

Never heard of conky before. Looks cool.

What I would do here:

Do not call the executable each time but have jack_cpu_load write into a "circular buffer" (I multiply by 100 because I'm not sure what conky does to floats)

stdbuf -oL jack_cpu_load | grep --line-buffered "jack DSP load" | stdbuf -oL cut -d' ' -f4 | while read line; do echo "scale=0; $line*100/1" | bc -l > /tmp/buffer; done &

Read the buffer from conky:

${tail /tmp/buffer 1 1}

Or draw a bar

${execbar cat /tmp/buffer}


${execibar 1 cat /tmp/buffer}

I have no X here, but I'll let you try :)

PS. Also found this on stack overflow (https://stackoverflow.com/questions/5427936/mpd-lua-conky) which shows other possibilities

  • This is very, very close to what I need. The only problem is that when this number really matters it is >1. I can probably figure it out from here though. Thank you very much!
    – user57649
    Jan 27 '14 at 0:47
  • Here's what I'm going with: stdbuf -oL jack_cpu_load | grep --line-buffered "jack DSP load" | stdbuf -oL cut -d' ' -f4 | stdbuf -oL sed -e 's/.\{4\}$//' > /tmp/buffer &
    – user57649
    Jan 27 '14 at 3:14
  • Just be careful that /tmp/buffer doesnt fill your disk when you dont go on a line per line basis, and that actually the last item is used by conky.
    – Marki
    Jan 27 '14 at 12:25
  • Okay. How's this: stdbuf -oL jack_cpu_load | grep --line-buffered "jack DSP load" | stdbuf -oL cut -d' ' -f4 | while read line; do echo "$line*100/1" | stdbuf -oL sed -e 's/.\{10\}$//' > /tmp/buffer; done & The output looks the way I want.
    – user57649
    Jan 27 '14 at 15:07
  • You left the $line*100 but no bc (calculator) anymore. I haven't tried but I wonder if the output really is what you want.
    – Marki
    Jan 27 '14 at 16:41

you need execpi instead of execp

   execpi interval command
          Same as execp but with specific interval.  Interval can't be less than update_interval in configuration. Note that the output from the $execpi com‐
          mand is still parsed and evaluated at every interval.
  • Thanks. The output still isn't showing, but I'll keep that in mind.
    – user57649
    Jan 27 '14 at 0:03
  • did you use the interval setting?
    – user55518
    Jan 27 '14 at 0:08
  • I tried ${execpi 6 /home/bin/dsp.sh} and ${execpi 10 /home/bin/dsp.sh} either should be plenty of time but no output.
    – user57649
    Jan 27 '14 at 0:25

Try to giving more room for text with "text_buffer_size".

  • Questions to the OP should go in comments, which you can provide once you have enough reputation on this site. As it is (and since stdbuf has not text_buffer_size option), it is not clear to me how your answer could help the OP without further details.
    – Anthon
    Apr 3 '14 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.