You are not logged in.

#1 2020-07-08 16:23:43

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,565

[Solved] Problem with conky-parse(str) in lua script

I have decided to 'modernize' my conky scripts, into the new syntax. For one script, lua is not parsing the right values.
I have this lua script for creating rings with the following settings. I won't paste the whole thing since it's fairly repetitively obvious:

settings_table = {
    {
        name='cpu',
        arg='cpu0',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.105,
        fg_colour=0xffffff,
        fg_alpha=1.0,
        x=290, y=710,
        radius=135,
        thickness=15,
        start_angle=-90,
        end_angle=180
    },
    {
        name='cpu',
        arg='cpu1',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.15,
        fg_colour=0xffffff,
        fg_alpha=1.0,
        x=290, y=710,
        radius=120,
        thickness=15,
        start_angle=-90,
        end_angle=180
    }, 
    {
        name='cpu',
        arg='cpu2',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.175,
        fg_colour=0xffffff,
        fg_alpha=1.0,
        x=290, y=710,
        radius=105,
        thickness=15,
        start_angle=-90,
        end_angle=180
    },
    ... (the rest of the cpu variables continue 8 in total as there are 8 threads)
     {
        name='memperc',
        arg='',
        name='fs_used_perc',
        arg='/',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.1,
        fg_colour=0xffffff,
        fg_alpha=0.8,
        x=288, y=380,
        radius=135,
        thickness=29,
        start_angle=0,
        end_angle=270
    },
    {
        name='fs_used_perc',
        arg='/home',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.15,
        fg_colour=0xffffff,
        fg_alpha=0.8,
        x=288, y=380,
        radius=104,
        thickness=29,
        start_angle=0,
        end_angle=270
    },
    {
        name='fs_used_perc',
        arg='/home/datapool',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.2,
        fg_colour=0xffffff,
        fg_alpha=0.8,
        x=288, y=380,
        radius=73,
        thickness=29,
        start_angle=0,
        end_angle=270
    },	
   {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0xffffff,
        bg_alpha=0.25,
        fg_colour=0xffffff,
        fg_alpha=0.8,
        x=288, y=380,
        radius=42,
        thickness=29,
        start_angle=0,
        end_angle=270
    }
}

And I have this function to parse the variables in the settings_table. It is taken from lua API conky_parse(string). I have included a print() function to check the output of the string parsing in terminal:

function setup_rings(cr,pt)
    local str=''
    local value=0
        
    str=string.format('${%s %s}',pt['name'],pt['arg'])
    val=conky_parse(str)

    -- check value of the parsing --
    print(val)
        
    value=tonumber(val)
    pct=value/pt['max']
        
    draw_ring(cr,pct,pt)
end

The problem is conky_parse is not parsing the cpu variables while the others are fine. So for one conky interval,  the print(val) output in the terminal looks like:

0
0
0
0
0
0
0
0
72
59
51
24

As you can see, the ${cpu cpu_n} variables parses to 0 while the rest is fine. So for my conky cpu rings, nothing is registering. However if I print the variables in conky as text, the cpu values show correctly so it's definitely an issue with parsing in lua.
I am using conky-lua-nv from AUR.
Am I missing something here? Is anybody experiencing the same problem?

Last edited by d_fajardo (2020-07-08 22:24:27)

Offline

#2 2020-07-08 22:24:07

d_fajardo
Member
Registered: 2017-07-28
Posts: 1,565

Re: [Solved] Problem with conky-parse(str) in lua script

It seems the conky-lua-nv package is buggy. I installed conky-cairo instead and everything works as expected.

Offline

Board footer

Powered by FluxBB