ENH split update and dynamic drawing functions
This commit is contained in:
parent
bdbcf0ab75
commit
73c8396a30
|
@ -63,13 +63,15 @@ return function()
|
|||
-----------------------------------------------------------------------------
|
||||
-- main functions
|
||||
|
||||
local update = function()
|
||||
local smart_pid = Util.execute_cmd('pidof smartd', nil, '*n')
|
||||
Common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
|
||||
local update = function(trigger)
|
||||
if trigger == 0 then
|
||||
local smart_pid = Util.execute_cmd('pidof smartd', nil, '*n')
|
||||
Common.text_row_set(smart, (smart_pid == '') and 'Error' or 'Running')
|
||||
|
||||
for i = 1, FS_NUM do
|
||||
local percent = Util.conky_numeric(CONKY_USED_PERC[i])
|
||||
Common.compound_bar_set(fs, i, percent * 0.01)
|
||||
for i = 1, FS_NUM do
|
||||
local percent = Util.conky_numeric(CONKY_USED_PERC[i])
|
||||
Common.compound_bar_set(fs, i, percent * 0.01)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -80,11 +82,11 @@ return function()
|
|||
Common.compound_bar_draw_static(fs, cr)
|
||||
end
|
||||
|
||||
local draw_dynamic = function(cr, trigger)
|
||||
if trigger == 0 then update() end
|
||||
local draw_dynamic = function(cr)
|
||||
-- if trigger == 0 then update() end
|
||||
Common.text_row_draw_dynamic(smart, cr)
|
||||
Common.compound_bar_draw_dynamic(fs, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -206,7 +206,7 @@ return function(update_freq)
|
|||
end
|
||||
|
||||
local draw_dynamic = function(cr)
|
||||
update()
|
||||
-- update()
|
||||
|
||||
Common.text_row_draw_dynamic(status, cr)
|
||||
Common.text_row_crit_draw_dynamic(internal_temp, cr)
|
||||
|
@ -216,5 +216,5 @@ return function(update_freq)
|
|||
Common.percent_plot_draw_dynamic(vid_util, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -183,7 +183,7 @@ return function(update_freq)
|
|||
end
|
||||
|
||||
local draw_dynamic = function(cr)
|
||||
update()
|
||||
-- update()
|
||||
|
||||
Common.dial_draw_dynamic(mem, cr)
|
||||
Common.dial_draw_dynamic(swap, cr)
|
||||
|
@ -195,5 +195,5 @@ return function(update_freq)
|
|||
Table.draw_dynamic(tbl, cr)
|
||||
end
|
||||
|
||||
return {dynamic = draw_dynamic, static = draw_static}
|
||||
return {dynamic = draw_dynamic, static = draw_static, update = update}
|
||||
end
|
||||
|
|
|
@ -101,10 +101,10 @@ return function(update_freq)
|
|||
end
|
||||
|
||||
local draw_dynamic = function(cr)
|
||||
update()
|
||||
-- update()
|
||||
Common.annotated_scale_plot_draw_dynamic(rx, cr)
|
||||
Common.annotated_scale_plot_draw_dynamic(tx, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -42,10 +42,10 @@ return function()
|
|||
Common.text_rows_draw_static(rows, cr)
|
||||
end
|
||||
|
||||
local draw_dynamic = function(cr, pacman_stats)
|
||||
update(pacman_stats)
|
||||
local draw_dynamic = function(cr)
|
||||
-- update(pacman_stats)
|
||||
Common.text_rows_draw_dynamic(rows, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -127,12 +127,12 @@ return function(update_freq)
|
|||
Common.annotated_scale_plot_draw_static(bat, cr)
|
||||
end
|
||||
|
||||
local draw_dynamic = function(cr, is_using_ac)
|
||||
update(is_using_ac)
|
||||
local draw_dynamic = function(cr)
|
||||
-- update(is_using_ac)
|
||||
Common.annotated_scale_plot_draw_dynamic(pkg0, cr)
|
||||
Common.annotated_scale_plot_draw_dynamic(dram, cr)
|
||||
Common.annotated_scale_plot_draw_dynamic(bat, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -186,8 +186,8 @@ return function(update_freq)
|
|||
Table.draw_static(tbl, cr)
|
||||
end
|
||||
|
||||
local draw_dynamic = function(cr, trigger)
|
||||
update(trigger)
|
||||
local draw_dynamic = function(cr)
|
||||
-- update(trigger)
|
||||
|
||||
for i = 1, #cores do
|
||||
CompoundDial.draw_dynamic(cores[i].loads, cr)
|
||||
|
@ -200,5 +200,5 @@ return function(update_freq)
|
|||
Table.draw_dynamic(tbl, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -98,10 +98,10 @@ return function(update_freq)
|
|||
end
|
||||
|
||||
local draw_dynamic = function(cr)
|
||||
update()
|
||||
-- update()
|
||||
Common.annotated_scale_plot_draw_dynamic(reads, cr)
|
||||
Common.annotated_scale_plot_draw_dynamic(writes, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
|
@ -22,12 +22,7 @@ return function()
|
|||
{'Kernel', 'Uptime', 'Last Upgrade', 'Last Sync'}
|
||||
)
|
||||
|
||||
local draw_static = function(cr)
|
||||
Common.drawHeader(cr, header)
|
||||
Common.text_rows_draw_static(rows, cr)
|
||||
end
|
||||
|
||||
local draw_dynamic = function(cr, pacman_stats)
|
||||
local update = function(pacman_stats)
|
||||
local last_update, last_sync = "N/A", "N/A"
|
||||
if pacman_stats then
|
||||
last_update, last_sync = __string_match(pacman_stats, "^%d+%s+([^%s]+)%s+([^%s]+).*")
|
||||
|
@ -37,8 +32,16 @@ return function()
|
|||
Common.text_rows_set(rows, 2, Util.conky('$uptime'))
|
||||
Common.text_rows_set(rows, 3, last_update)
|
||||
Common.text_rows_set(rows, 4, last_sync)
|
||||
end
|
||||
|
||||
local draw_static = function(cr)
|
||||
Common.drawHeader(cr, header)
|
||||
Common.text_rows_draw_static(rows, cr)
|
||||
end
|
||||
|
||||
local draw_dynamic = function(cr)
|
||||
Common.text_rows_draw_dynamic(rows, cr)
|
||||
end
|
||||
|
||||
return {static = draw_static, dynamic = draw_dynamic}
|
||||
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
||||
end
|
||||
|
|
37
main.lua
37
main.lua
|
@ -60,34 +60,33 @@ function conky_start(update_interval)
|
|||
local STATS_FILE = '/tmp/.conky_pacman'
|
||||
|
||||
draw_dynamic = function(cr, _updates)
|
||||
-- timings of each line when cpu set to performance
|
||||
-- 0.7ms
|
||||
-- draw static components
|
||||
draw_static(cr)
|
||||
|
||||
-- update dynamic components
|
||||
local t1 = _updates % (update_freq * 10)
|
||||
local pacman_stats = Util.read_file(STATS_FILE)
|
||||
-- 0.1ms
|
||||
local is_using_ac = using_ac()
|
||||
|
||||
-- <0.1ms
|
||||
sys.dynamic(cr, pacman_stats)
|
||||
-- 0.3ms
|
||||
sys.update(pacman_stats)
|
||||
gfx.update()
|
||||
proc.update(t1)
|
||||
rw.update()
|
||||
net.update()
|
||||
pcm.update(pacman_stats)
|
||||
fs.update(t1)
|
||||
pwr.update(is_using_ac)
|
||||
mem.update()
|
||||
|
||||
-- draw dynamic components
|
||||
sys.dynamic(cr)
|
||||
gfx.dynamic(cr)
|
||||
-- 0.8-1.1ms
|
||||
proc.dynamic(cr, t1)
|
||||
|
||||
-- 0.1-0.3ms
|
||||
proc.dynamic(cr)
|
||||
rw.dynamic(cr)
|
||||
-- 0.2ms
|
||||
net.dynamic(cr)
|
||||
|
||||
-- <0.1ms
|
||||
pcm.dynamic(cr, pacman_stats)
|
||||
-- <0.1ms
|
||||
fs.dynamic(cr, t1)
|
||||
-- 0.3ms
|
||||
pwr.dynamic(cr, is_using_ac)
|
||||
-- 0.5ms
|
||||
pcm.dynamic(cr)
|
||||
fs.dynamic(cr)
|
||||
pwr.dynamic(cr)
|
||||
mem.dynamic(cr)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue