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.27k stars 620 forks source link

Read cpu percentage in lua fails #1108

Closed ManuelTS closed 1 year ago

ManuelTS commented 3 years ago

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 = [[
]]
Dusty211 commented 3 years ago

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.

eikenb commented 3 years ago

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.

TanawatJukmongkol commented 2 years ago

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

TanawatJukmongkol commented 2 years ago

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.

github-actions[bot] commented 1 year ago

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] commented 1 year ago

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

HorlogeSkynet commented 1 year ago

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