I had a simple conky script for the Deadbeef audio player:

enter image description here

The part that is concerned with the lines above is this:

${color 3399FF}${alignr}db audio is playing: 
${color FFFFFF}${alignr} ${exec deadbeef --nowplaying "%a"} 
${color FFFFFF} ${alignr}${exec deadbeef --nowplaying "%t"}
${color FFFFFF}${alignr}${exec deadbeef --nowplaying "%b"} 
${color FFFFFF}
${alignr}${color 3399FF}${exec deadbeef --nowplaying "%e"}${offset 2}${alignr} / ${exec deadbeef --nowplaying "%l"} 
${alignr}${image ./logo.png -p 0,-1 -s 25x25}${color 3399FF}

How do I add a progress bar, showing the progress through the song?


You can draw a default-sized bar using execbar followed by a command that should return a number from 0 to 100 giving what percentage of the bar is filled. For example, if you have the following shell script myscript in your PATH:

deadbeef --nowplaying "%e %l" |
awk '
{ n = split("::" $1,t,":")
  elapsed = (t[n-2]*60+t[n-1])*60+t[n]
  n = split("::" $2,t,":")
  total = (t[n-2]*60+t[n-1])*60+t[n]
  printf "%d\n",elapsed*100/total

then you can use the conky line:

${execbar myscript}

The script simply converts the elapsed and total time output from deadbeef into seconds and finally a percentage.

The result looks like this:

enter image description here

  • please help again. the bar shows but without progress. I have edited the question accordingly – user32012 Apr 27 '17 at 9:49
  • 1
    I'm not sure why you are not seeing any progress. It is as if execbar is not getting any value from the script. Check when your run deadbeef_bar from your command line in a terminal that you get a number growing from 0 to 100 as the music progresses. Run conky from the command line and check it prints no error messages as it runs. Check that your ~/bin directory is in your PATH for conky. Try putting the full pathname instead of just deadbeef_bar in the execbar command. It is probably something simple. – meuh Apr 27 '17 at 14:31
  • It was the full path that was needed, in my case ~/bin/deadbeef_bar. – user32012 Apr 27 '17 at 14:53

I was looking for a way to do this as well, and since I already was using a lua script for my conky file, I decided to create a lua function to do this so I didn't have to rely on external bash scripts.

If anyone is interested in going this route, you need to include your lua file in your conkyrc in the conky.config section:

conky.config = {
   ...other config options...,    
   lua_load         = '/path/to/file.lua'

then in your lua file you need the following function (note that this is using deadbeef's new foobar formatting syntax that came with deadbeef 0.7.0, which not only is more future proof as the old syntax is being deprecated, but simplifies the calculations) [fixed a stupid typo I just noticed I had]:

function conky_song_progress()
   local song_progress = "deadbeef --nowplaying-tf '(100*%playback_time_seconds%)//%length_seconds_fp%' 2>/dev/null"
   local get_progress = assert(io.popen(song_progress))
   local progress     = math.tointeger(assert(loadstring("return " .. get_progress:read('*all')))())
   return progress

Then add into your conky.text section:

${lua_bar song_progress}

Note as well that this is using the new conky 1.10 syntax and the lua code needs lua 5.3+.

Your Answer

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