ENH fix threshold source agreement issues

This commit is contained in:
Nathan Dwarshuis 2021-11-10 12:24:13 -05:00
parent 328201a228
commit 70489cd7f2
4 changed files with 18 additions and 13 deletions

2
core

@ -1 +1 @@
Subproject commit 015b909d5c62aedab6903a389c74aec40550efc6 Subproject commit 40bf74d8c6f4e80981bcec3e9902967b6570c118

View File

@ -363,7 +363,7 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- ring with text data in the center -- ring with text data in the center
M.make_text_circle = function(x, y, r, fmt, limit) M.make_text_circle = function(x, y, r, fmt, threshhold)
return { return {
ring = M.make_circle(x, y, r), ring = M.make_circle(x, y, r),
value = text_threshold.make_formatted( value = text_threshold.make_formatted(
@ -371,7 +371,7 @@ M.make_text_circle = function(x, y, r, fmt, limit)
0, 0,
text.config(normal_font_spec, theme.PRIMARY_FG, 'center', 'center'), text.config(normal_font_spec, theme.PRIMARY_FG, 'center', 'center'),
fmt, fmt,
text_threshold.config(theme.CRITICAL_FG, limit) text_threshold.config(theme.CRITICAL_FG, threshhold)
), ),
} }
end end
@ -399,14 +399,14 @@ local threshold_indicator = function(threshold)
) )
end end
M.make_dial = function(x, y, radius, thickness, threshold, format) M.make_dial = function(x, y, radius, thickness, threshold, _format)
return { return {
dial = dial.make( dial = dial.make(
geom.make_arc(x, y, radius, DIAL_THETA0, DIAL_THETA1), geom.make_arc(x, y, radius, DIAL_THETA0, DIAL_THETA1),
arc.config(style.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG), arc.config(style.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG),
threshold_indicator(threshold) threshold_indicator(threshold)
), ),
text_circle = M.make_text_circle(x, y, radius - thickness / 2 - 2, format, threshold), text_circle = M.make_text_circle(x, y, radius - thickness / 2 - 2, _format, threshold),
} }
end end

View File

@ -5,6 +5,7 @@ local common = require 'common'
local geometry = require 'geometry' local geometry = require 'geometry'
local pure = require 'pure' local pure = require 'pure'
return function(update_freq) return function(update_freq)
local MODULE_Y = 712 local MODULE_Y = 712
local DIAL_THICKNESS = 8 local DIAL_THICKNESS = 8
@ -26,6 +27,7 @@ return function(update_freq)
'\nSReclaimable:%s+(%d+)' '\nSReclaimable:%s+(%d+)'
local __string_match = string.match local __string_match = string.match
local __math_floor = math.floor
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- header -- header
@ -48,7 +50,7 @@ return function(update_freq)
local swaptotal = get_meminfo_field('SwapTotal') local swaptotal = get_meminfo_field('SwapTotal')
local FORMAT_PERCENT = function(x) local FORMAT_PERCENT = function(x)
return string.format('%.0f%%', x * 100) return string.format('%i%%', __math_floor(x))
end end
local MEM_X = geometry.RIGHT_X + DIAL_RADIUS + DIAL_THICKNESS / 2 local MEM_X = geometry.RIGHT_X + DIAL_RADIUS + DIAL_THICKNESS / 2
@ -60,7 +62,7 @@ return function(update_freq)
MEM_Y, MEM_Y,
DIAL_RADIUS, DIAL_RADIUS,
DIAL_THICKNESS, DIAL_THICKNESS,
0.8, 80,
FORMAT_PERCENT FORMAT_PERCENT
) )
@ -74,7 +76,7 @@ return function(update_freq)
MEM_Y, MEM_Y,
DIAL_RADIUS, DIAL_RADIUS,
DIAL_THICKNESS, DIAL_THICKNESS,
0.8, 80,
FORMAT_PERCENT FORMAT_PERCENT
) )
@ -150,8 +152,8 @@ return function(update_freq)
buffers - buffers -
sreclaimable) / memtotal sreclaimable) / memtotal
common.dial_set(mem, used_percent) common.dial_set(mem, used_percent * 100)
common.dial_set(swap, (swaptotal - swapfree) / swaptotal) common.dial_set(swap, (swaptotal - swapfree) / swaptotal * 100)
common.text_rows_set(cache, 1, cached / memtotal * 100) common.text_rows_set(cache, 1, cached / memtotal * 100)
common.text_rows_set(cache, 2, buffers / memtotal * 100) common.text_rows_set(cache, 2, buffers / memtotal * 100)

View File

@ -52,7 +52,7 @@ return function(update_freq)
DIAL_OUTER_RADIUS, DIAL_OUTER_RADIUS,
DIAL_INNER_RADIUS, DIAL_INNER_RADIUS,
DIAL_THICKNESS, DIAL_THICKNESS,
0.8, 80,
nthreads nthreads
), ),
coretemp = common.make_text_circle( coretemp = common.make_text_circle(
@ -60,7 +60,7 @@ return function(update_freq)
y, y,
DIAL_INNER_RADIUS - 2, DIAL_INNER_RADIUS - 2,
'%s°C', '%s°C',
90 80
) )
} }
end end
@ -141,7 +141,10 @@ return function(update_freq)
for _, load_data in pairs(cpu_loads) do for _, load_data in pairs(cpu_loads) do
local cur = load_data.percent_active local cur = load_data.percent_active
load_sum = load_sum + cur load_sum = load_sum + cur
compound_dial.set(cores[load_data.conky_core_id].loads, load_data.conky_thread_id, cur) compound_dial.set(
cores[load_data.conky_core_id].loads,
load_data.conky_thread_id,
cur * 100)
end end
for conky_core_id, path in pairs(coretemp_paths) do for conky_core_id, path in pairs(coretemp_paths) do