I started playing with Conky a few days ago and managed to achieve this:

(Note: although I've written it from scratch, I got inspired by this photo, credits to the author for their creativity)

As you can see, I have some free space between the digital clock ("21:20") and the connection statistics.

Now I'd love to have what I called "music bars" in that space. That is, animated bars that move following the sound currently played by my music player (which is Clementine at the moment). I've already managed to display the current track, artist, year, etc. thanks to some scripts and the qbus command.

However, I have to main questions:

  • How would I get the actual music data (I think it's called amplitudes)?
  • How would I animate that in a fairly smooth way?

I'm using conky and lua with cairographics, but animation really seems to be something complicated, as I haven't found a way to make lua/cairographics "repaint". This forces me to reduce the update_interval in .conkyrc to achieve something "close" to an animation.

Unfortunately, setting a very small value to update_interval makes conky consume a lot of CPU resources, because it doesn't only redraw every (for example) 50 milliseconds, but it also recalculates variables and re-executes scripts if necessary.

Therefore, for the animation, I'm looking for a way have a smooth animation (10 fps would be enough) without making conky eat up the CPU resources.

It would be awesome if anybody could give me some ideas. It does not necessarily have to be in LUA, and if there's a good alternative to conky (should be something lightweight), feel free to let me know!


Thanks a lot for the ideas and suggestions!

  • 1
    This is close to impossible IMHO. You'll need to intercept and buffer audio data played by your player, then analyse it, to get info you are looking for. – zetah Jan 22 '12 at 21:00
  • As long as it's acceptable in terms of performance (conky should remain lightweight), I don't mind doing complicated things. :-) However, I'm starting to think the main issue is the actual animation... – Eti Jan 23 '12 at 0:18
  • I don't use conky, but from what I see I doubt it's designed to do more then one cycle per second while being usable. Let aside you'll have to do PSD on buffered signal and average it on bins that would be presented in your bars. It has nothing to do with amplitude and sorry to suggest, but I would just forget about it – zetah Jan 23 '12 at 0:39
  • @zetah Indeed, but I think cairographics (which can used by conky, as I did) allows pretty advanced 2D drawing. If only I could find a way to make cairo redraw multiple times within one conky interval, a whole lot of problems would be solved! – Eti Jan 23 '12 at 1:09

I think it is possible, using PulseAudio. I don't know how to go about it fully, but here is a utility I found that'll help you get the amplitudes - I suppose you could then find something to convert that into conky charts.

| improve this answer | |
  • Now that's something useful! Thanks for your post. Yes, turning that into bars shouldn't be a big deal. My main concern is the update interval though... Having the bars move only once every second wouldn't look very exceptionnel I guess. :) – Eti Jan 22 '12 at 21:28
  • 1
    Well, no - but you could either ask the author or modify it yourself to check on shorter intervals. It only checks once a second with this code: if (now < time(NULL)) { now = time(NULL); time being a function that returns second precision: cplusplus.com/reference/clibrary/ctime/time or you could remove the check entirely, though I'm not sure how fast would it be checking then (could be checking all the time and wasting your cpu) – Vadim Peretokin Jan 24 '12 at 4:43

I know it has been quite a while since you posted this, however I found a great CLI visualizer the other day: https://github.com/dpayne/cli-visualizer

Now, this does not solve your update interval issue of course, but you still might find it as interesting as I do.

| improve this answer | |

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.