conky icon indicating copy to clipboard operation
conky copied to clipboard

Read cpu percentage in lua fails

Open ManuelTS opened this issue 3 years ago • 4 comments

Issue

On Ubuntu 21.04 x64 on a Thinkpad p1 g3 the reading the CPU within a .lua file with

local value = conky_parse ("${cpu cpu0}")
local value1 = conky_parse ("${cpu}")
print(value)
print(value1)

is always 0. Other operations as top cpu 0 however deliver values.

Information I read the CPU in ~/.config/conky/main.lua with my config ~/.config/conky/conky.conf:

-- http://conky.sourceforge.net/config_settings.html
conky.config = {
    -- Window
    alignment = 'top_right',
    gap_x = 5,
    gap_y = 35,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'desktop', -- desktop or normal
    double_buffer = true,
    use_xft = true,
    update_interval = 3.0,
    minimum_height = 490,
    minimum_width = 280,
    -- Lua
    lua_load = "/home/hl/.config/conky/main.lua",
    lua_draw_hook_post = "main"
}

conky.text = [[
]]

ManuelTS avatar May 26 '21 16:05 ManuelTS

Issue

On Ubuntu 21.04 x64 on a Thinkpad p1 g3 the reading the CPU within a .lua file with

local value = conky_parse ("${cpu cpu0}")
local value1 = conky_parse ("${cpu}")
print(value)
print(value1)

is always 0. Other operations as top cpu 0 however deliver values.

Information I read the CPU in ~/.config/conky/main.lua with my config ~/.config/conky/conky.conf:

-- http://conky.sourceforge.net/config_settings.html
conky.config = {
    -- Window
    alignment = 'top_right',
    gap_x = 5,
    gap_y = 35,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'desktop', -- desktop or normal
    double_buffer = true,
    use_xft = true,
    update_interval = 3.0,
    minimum_height = 490,
    minimum_width = 280,
    -- Lua
    lua_load = "/home/hl/.config/conky/main.lua",
    lua_draw_hook_post = "main"
}

conky.text = [[
]]

@ManuelTS I ran into This same issue; However, If I add ${cpu cpu0} to the text part of my conkyrc file, the LUA rings which are specified in a separate LUA script that conkyrc calls start working again strangely.

Dusty211 avatar Jul 27 '21 17:07 Dusty211

I also found this issue after upgrade to Debian 11 (Conky 1.11.6).

I also have an all Lua setup and have 0 values for both ${cpu} and ${ibm_fan} when referenced in the Lua with conky_parse(). I also can confirm that if you add them to the text (eg. conky.text= [[ ${cpu} ${ibm_fan } ]] ) then they render properly in the lua as well.

I'm fixing this by downgrading to 1.10.8, which worked without issue.

eikenb avatar Sep 14 '21 02:09 eikenb

Have this issues as well. Not just $cpu, but $upspeed and $downspeed also!

TanawatJukmongkol avatar May 18 '22 14:05 TanawatJukmongkol

I ran into This same issue; However, If I add ${cpu cpu0} to the text part of my conkyrc file, the LUA rings which are specified in a separate LUA script that conkyrc calls start working again strangely.

Same! Probably because conky doesn't load those data onto the formatted strings aka conky.text = [[ ... ]], to save up computation time, and memory usage. They should just add a method to enable loading the data.

TanawatJukmongkol avatar May 18 '22 14:05 TanawatJukmongkol

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment, or this issue will be closed in 30 days.

github-actions[bot] avatar May 19 '23 01:05 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity.

github-actions[bot] avatar Jun 18 '23 02:06 github-actions[bot]

AFAIK, this issue still persists. Can it be re-opened ? :slightly_smiling_face:

HorlogeSkynet avatar Jun 18 '23 06:06 HorlogeSkynet