brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.17k stars 615 forks source link

[Bug]: Execbar cannot access variables (w/o error) that Exec can, on startup. (Lua/Conky_Parse) #1699

Open mzmncb opened 9 months ago

mzmncb commented 9 months ago

What happened?

When using conky_parse in a Lua script, a template using Execbar will (temporarily) not be able to access variables passed to it, even when they are available. After a few seconds (cycles?), Execbar does access the variables without error.

However, a template using Exec -can- access those same variables just fine at startup, without errors.

Even if a value is hardcoded into the template instead of passed in as an argument, the Execbar template will still throw an error on startup.

Version

conky 1.13.1 compiled 2022-10-02 for Linux x86_64

Which OS/distro are you seeing the problem on?

Linux (other)

Conky config

==========
conky conf
==========

conky.config = {
    own_window_class = 'Conky',
    own_window_title = 'Conky',
    own_window_type = 'normal',
    cpu_avg_samples = 2,
    double_buffer = true,
    net_avg_samples = 2,
    no_buffers = true,
    out_to_x = true,
    own_window = true,
    update_interval = 1,
    use_xft = true,
    lua_load = '.../test-1.lua',
    template0 = "${exec [ -n \"\\1\" ] && echo \"33 66 99\"}",
    template1 = "${exec echo \"\\1 \\2 \\3 \\4\"}",
    template2 = "${execbar 4,125 echo \"\\4\"}"
}

conky.text = [[
Test-1:
${lua eval_tpl template1 arg1 ${template0 arg1}}
# --> [exec] No error when reading variables on initial load

${lua eval_tpl template2 arg1 ${template0 arg1}}
# --> [execbar] Error when reading variables on initial load
# --> conky: reading exec value failed (perhaps it's not the correct format?)
]]

==========
lua_load code
==========

ct = 0
function conky_eval_tpl(arg0, arg1, t1)
  print(ct)

  p1 = conky_parse(t1)

  print("p1 [" .. p1 .. "]")

  t2 = "${" .. arg0 .. " " .. arg1 .. " " .. p1 .. "}"

  print("t2 [" .. t2 .. "]")

  p2 = conky_parse(t2)

  print()

  ct = ct + 1
  return p2
end

Stack trace

No response

Relevant log output

$ conky -c .../test-1.conf;
conky: desktop window (3f3) is root window
conky: window type - normal
conky: drawing to created window (0x4600001)
conky: drawing to double buffer
0
p1 []
t2 [${template1 arg1 }]
--> template1 [Exec]:       values missing, but no error

1
p1 []
t2 [${template2 arg1 }]
conky: reading exec value failed (perhaps it's not the correct format?)
--> template2 [Execbar]:    values missing, and error

2
p1 [33 66 99]
t2 [${template1 arg1 33 66 99}]
--> template1 [Exec]:       values present, no error

3
p1 [33 66 99]
t2 [${template2 arg1 33 66 99}]
conky: reading exec value failed (perhaps it's not the correct format?)
--> template2 [Execbar]:    values present, but still reports an error

4
p1 [33 66 99]
t2 [${template1 arg1 33 66 99}]
--> template1 [Exec]:       values present, no error

5
p1 [33 66 99]
t2 [${template2 arg1 33 66 99}]
--> template2 [Execbar]:    values present, error stops...

...

--> no more errors...
mzmncb commented 9 months ago

Not sure if it's OK to repost this. My first post was removed (#1697).

Caellian commented 5 months ago

Not sure if it's OK to repost this. My first post was removed.

It's ok, not sure why it was removed.