0

I have the exact same issue as Creating Conky text variables with zero padding? for displaying network speed. Except that I'm piping conky to dzen2. It seems lua_parse is not working within that setup.

I've tried :

  1. Formatting the string directly : ${lua_parse format %2s ${downspeed re0}}
  2. Using goto : ${downspeed re0}${goto 100}
  3. Setting a custom function in ~/.xmonad/conky_lua_script.lua :
function conky_format( format, number )
    return string.format( format, conky_parse( number ) )
end

Then in conkyrc:

lua_load = "~/.xmonad/conky_lua_script.lua"

conky.text = [[ ${lua_parse format %5.0f ${downspeed re0}}% ]];

Minimal working example :

conky.config = {
    background = true,
    out_to_console = true,
    out_to_x = false,
    update_interval = 1.0,
    use_spacer = 'none',
    use_xft = true
};

conky.text = [[ ${downspeed re0} ]];

Run it with conky | dzen2 .

Edit The following works :

conky.config = {
    lua_load = "~/.xmonad/conky_lua_script.lua"
    ....
};

conky.text = [[ ${lua format %7s ${downspeed re0}} ]];

  • 1
    Are you using a monospaced font in dzen2? Otherwise the text is bound to move. Are you using format_human_readable = false, with use_spacer = 'left', in conky? – meuh Feb 19 '21 at 16:27
  • 1
    I was setting DejaVu Sans Mono in conky but it seems like it did nothing. With a monospace font in dzen instead anduser_spacer = 'left' in conky, it's much better. Text still moves when switching units though. I did not set format_human_readable = false, as it made speeds hard to read. So the best solution for now is to used downspeedf instead of downspeed for fixed text. I still prefer the output of downspeed though :) – alex_reader Feb 19 '21 at 17:18

1 Answers1

3

I realize this is a pretty stale question, but I recently ran into the same problem and this was high on the search results. Since I was able to uncover the answer, I figured I'd post it for the sake of anyone else that runs into this problem.

The lua_load = ... must be in your conky.config table (and not at the top level of the file the way it was in the old config syntax). Something like this:

conky.config = {
    lua_load = 'path_to_script.lua',
    ...
};

Odd that even with debug enabled through -DD conky doesn't complain about the misplaced line.

Kopsis
  • 46