Skip to content

Trying to use this with Conky, but having some issues #13

@MostHated

Description

@MostHated

Hey there,
I am sure I am doing something incorrectly, but I am new to LUA, so I am not quite sure what I am doing wrong.

Here is essentially what I am trying to do:

Code block using sh
function parts.cputemp(colorBg)
  -- local command = "zsh -c \'/home/mosthated/_dev/languages/sh/temps.zsh \"Tccd1\"'"
  -- local temp = _h.exec("zsh -c \'/home/mosthated/_dev/languages/sh/temps.zsh \"Tccd1\"'")
  -- local temp = sh.command(command)

  -- Trying to run this command to return a single numeric value (30.1, 35.6, etc)
  local temp = sh.command('zsh','-c', '/home/mosthated/_dev/languages/sh/temps.zsh', 'Tccd1')

  local cputemp = [[\
  -- Then I wanted to reuse that same value throughout the rest of the script block
${if_match ]].. temp .. [[<45}\
]] .. _h.value(temp .. '°C', ci.good) .. [[
${else}${if_match ]].. temp ..[[<55}\
]] .. _h.value(temp .. '°C', ci.degraded) .. [[
${else}${if_match  ]]..  temp ..[[>=55}\
]] .. _h.value(temp .. '°C', ci.bad) .. [[
${endif}${endif}${endif}\
]]
  return _h.common('', 'CPU', cputemp, colorBg)
end
Unfortunately, when I attempt to use that code, I get the following message: `attempt to concatenate a function value (local 'temp')` After looking over the instructions again, I attempted to try this:
${if_match ]].. temp() .. [[<45}\
]] .. _h.value(temp() .. '°C', ci.good) .. [[

That then gives me the message of : attempt to call a table value

I also attempted to do tostring(temp()) but I believe that gave a message of: Bad arguments: 'function: 0x55c917c53460' and '45'

Might anyone have any insight on what I might need to change in order to properly get back the numeric value?

Thanks!
-MH

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions