0

execbar in conky does not seem to be working properly.

So if I do in a bash script (named myscript.sh)

# moc or mocp is Music on Console
totalsec=$(mocp --info | grep "TotalSec" | cut -d: -f2 | sed 's/^ //g' | sed 's/ $//g')
cursec=$(mocp --info | grep "CurrentSec" | cut -d: -f2 | sed 's/^ //g' | sed 's/ $//g')
progress=$(echo "(${cursec}*100/${totalsec})" | bc)
echo "\${execbar echo ${progress}}"
echo "${progress}" # This works and shows be the value of the integer variable.

and then call the bash script from conky using

conky.text = [[${execpi 3 ./myscript.sh}]];

then progress bar is not shown. Only a white rectangle.

However, if the same bash script is changed to

progress=23
echo "\${execbar echo ${progress}}"

then it works and shows a constant bar of 23. Don't know why passing a integer variable is not working. Any help to solve this problem will be appreciated.

ASarkar
  • 469
  • 5
  • 16
  • In trying to duplicate your results, I get conky showing the literal text `./myscript.sh` rather than a white rectangle or progress bar. I imagine your conky config file includes more than just the `conky.text` assignment statement. If so, please provide the entire contents of the conky config file you're using. – David Yockey Nov 30 '19 at 15:10
  • @DavidYockey: Sorry the conky.text looks like `conky.text = [[${execpi 3 ./music-info.sh}]];`. Updated my question. – ASarkar Dec 01 '19 at 10:56

1 Answers1

0

It turns out that execbar in a bash script can be made to work. Sort of.

To focus the problem on just the variable issue, I made a little script (myscript2.sh) that just gets the seconds from the current time for display in the bar...

#!/bin/bash
progress=$(date --date='now' +%S)
echo \${execbar echo ${progress}}

...and was able to get a periodically updated bar showing the seconds using this conky config file...

conky.config = {
    alignment = 'top_left',
    minimum_width = 300,
    own_window = true,
    own_window_hints = 'below',
    own_window_type = 'desktop',
    own_window_argb_visual=true,
    own_window_transparent = true,
    update_interval = 2.0,
}

conky.text = [[
${execpi 3 ./myscript2.sh}
]]

However, conky alternates bewteen showing the bar filled to the proper extent and showing the bar empty. In other words, the display of the bar contents blinks on and off. Yuck.

As an alternative, by using a script (myscript3.sh) to simply return the value to be displayed in the bar...

#!/bin/bash
progress=$(date --date='now' +%S)
echo $progress

...and changing the conky config file to use execibar rather than execpi...

conky.config = {
    alignment = 'top_left',
    minimum_width = 300,
    own_window = true,
    own_window_hints = 'below',
    own_window_type = 'desktop',
    own_window_argb_visual=true,
    own_window_transparent = true,
    update_interval = 2.0,
}

conky.text = [[
${execibar 3 ./myscript3.sh}
]]

...it appears to work as intended, without any blinking.

David Yockey
  • 595
  • 3
  • 11
  • Thanks for your detailed answer. Yes, your solution works. But it should have worked with `execpi` too. Unfortunately, I will not be able to use your method, since my bash script spits out other information which requires the usage of `execpi` – ASarkar Dec 04 '19 at 10:32