ENH optimize battery polling
This commit is contained in:
parent
07f2e89c77
commit
b9a140d445
|
@ -205,7 +205,7 @@ local update = function(cr)
|
||||||
CriticalText.set(core.coretemp_text, cr, Util.round_to_string(0.001 * Util.read_file(core.coretemp_path, nil, '*n')))
|
CriticalText.set(core.coretemp_text, cr, Util.round_to_string(0.001 * Util.read_file(core.coretemp_path, nil, '*n')))
|
||||||
end
|
end
|
||||||
|
|
||||||
local process_glob = Util.execute_cmd('ps -A -o s')
|
local process_glob = Util.execute_cmd('ps -A -o s h')
|
||||||
|
|
||||||
-- subtract one from running b/c ps will always be "running"
|
-- subtract one from running b/c ps will always be "running"
|
||||||
Text.set(process.value, cr,
|
Text.set(process.value, cr,
|
||||||
|
|
8
main.lua
8
main.lua
|
@ -169,7 +169,9 @@ cr_static = nil
|
||||||
-- create some useful functions
|
-- create some useful functions
|
||||||
--
|
--
|
||||||
local using_ac = function()
|
local using_ac = function()
|
||||||
return Util.read_file('/sys/class/power_supply/AC/online', nil, '*n') == 1
|
-- for some reason it is much more efficient to test if the battery
|
||||||
|
-- is off than if the ac is on
|
||||||
|
return Util.read_file('/sys/class/power_supply/BAT0/status') ~= 'Discharging'
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -184,8 +186,6 @@ function conky_main()
|
||||||
local _cw = conky_window
|
local _cw = conky_window
|
||||||
if not _cw then return end
|
if not _cw then return end
|
||||||
|
|
||||||
-- local time = os.clock()
|
|
||||||
|
|
||||||
local cs = __cairo_xlib_surface_create(_cw.display, _cw.drawable,
|
local cs = __cairo_xlib_surface_create(_cw.display, _cw.drawable,
|
||||||
_cw.visual, 1920, 1080)
|
_cw.visual, 1920, 1080)
|
||||||
local cr = __cairo_create(cs)
|
local cr = __cairo_create(cs)
|
||||||
|
@ -215,6 +215,4 @@ function conky_main()
|
||||||
__cairo_surface_destroy(cs)
|
__cairo_surface_destroy(cs)
|
||||||
__cairo_destroy(cr)
|
__cairo_destroy(cr)
|
||||||
__collectgarbage()
|
__collectgarbage()
|
||||||
|
|
||||||
-- print(os.clock() - time)
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue