You can do something simple like this, which uses execpi to run a shell script every 30 seconds that parses the output of df / and converts it into a long string of conky color commands and \# characters (since # is used for comments):
${execpi 30 df --output=pcent / | awk 'NR==2 {
n = ($1+0)/2; yellow = 20; red = 40;
if(n>=red) { r = "${color #ff0000}"; for(;n>=red;n--) r = r "\\#" }
if(n>=yellow){ y = "${color #ffff00}"; for(;n>=yellow;n--)y = y "\\#" }
g = "${color #00ff00}"; for(;n>0;n--) g = g "\\#";
print g y r
printf "%50s"," "
}' }
${color}
My df --output=pcent outputs 2 lines; the second one is a percentage used, eg 69%. I tried this on conky 1.9.
If your ~/.conkyrc file has been converted to format version 1.10 then it will contain a line
conky.text = [[
Make sure you add the above script before the final closing ]].
Also, in 1.10 colours given as numbers (eg #ff0000 above) no longer begin with # so you should use ff0000 and so on in the script.
To simplify, put the following script into a separate file somewhere in your PATH, say ~/mydf, make it executable (chmod +x ~/mydf), and then put that filename in ~/.conkyrc, eg ${execpi 30 ~/mydf /}
#!/bin/bash
df --output=pcent "${1?}" | awk 'NR==2{
n = ($1+0)/2; yellow = 20; red = 40;
if(n>=red) { r = "${color ff0000}"; for(;n>=red;n--) r = r "\\#" }
if(n>=yellow){ y = "${color ffff00}"; for(;n>=yellow;n--)y = y "\\#" }
g = "${color 00ff00}"; for(;n>0;n--) g = g "\\#";
print g y r
printf "%50s"," "
}'
If you want to put the whole script in the ~/.conkyrc file, you will need to increase the default buffer size or the command will be truncated to 256 characters. This leads to errors like
sh: -c: line 0: unexpected EOF while looking for matching `''
To do this, in 1.10 add a line inside the conky.config={...} part, making sure you separate the settings with a comma (,):
text_buffer_size = 400,
In conky 1.9 add a line before the TEXT section:
text_buffer_size 400
To stop the window resizing as the number of characters printed increases, a final printf "%50s"," " adds a second line of spaces of the maximum length. Alternatively, add a configuration setting for the minimum size of the window in pixels, eg minimum_size 500 (or minimum_size=500, for 1.10), where the value to use depends on the font width of the # character.