ADD font and cpu core count to config
This commit is contained in:
parent
d20a9637d1
commit
e5e83c5b79
15
config.yml
15
config.yml
|
@ -17,17 +17,18 @@ modules:
|
||||||
memory:
|
memory:
|
||||||
show_stats: true
|
show_stats: true
|
||||||
show_plot: true
|
show_plot: true
|
||||||
show_table: true
|
table_rows: 5
|
||||||
power:
|
power:
|
||||||
battery: BAT0
|
battery: BAT0
|
||||||
rapl_specs:
|
rapl_specs:
|
||||||
- {name: PKG0, address: intel-rapl:0}
|
- {name: PKG0, address: intel-rapl:0}
|
||||||
- {name: DRAM, address: intel-rapl:0:2}
|
- {name: DRAM, address: intel-rapl:0:2}
|
||||||
processor:
|
processor:
|
||||||
show_cores: true
|
core_rows: 1
|
||||||
|
core_padding: 0
|
||||||
show_stats: true
|
show_stats: true
|
||||||
show_plot: true
|
show_plot: true
|
||||||
show_table: true
|
table_rows: 5
|
||||||
readwrite:
|
readwrite:
|
||||||
devices: [sda, nvme0n1]
|
devices: [sda, nvme0n1]
|
||||||
|
|
||||||
|
@ -49,7 +50,13 @@ layout:
|
||||||
margins: [20, 10]
|
margins: [20, 10]
|
||||||
|
|
||||||
theme:
|
theme:
|
||||||
font: Neuropolitical
|
font:
|
||||||
|
family: Neuropolitical
|
||||||
|
sizes:
|
||||||
|
normal: 13
|
||||||
|
plot_label: 8
|
||||||
|
table: 11
|
||||||
|
header: 15
|
||||||
patterns:
|
patterns:
|
||||||
header: 0xefefef
|
header: 0xefefef
|
||||||
panel:
|
panel:
|
||||||
|
|
|
@ -56,17 +56,13 @@ return function(config)
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local patterns = compile_patterns(config.theme.patterns)
|
local patterns = compile_patterns(config.theme.patterns)
|
||||||
|
local font = config.theme.font
|
||||||
|
local font_sizes = font.sizes
|
||||||
|
local font_family = font.family
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- constants
|
-- constants
|
||||||
|
|
||||||
local FONT = config.theme.font
|
|
||||||
|
|
||||||
local NORMAL_FONT_SIZE = 13
|
|
||||||
local PLOT_LABEL_FONT_SIZE = 8
|
|
||||||
local TABLE_FONT_SIZE = 11
|
|
||||||
local HEADER_FONT_SIZE = 15
|
|
||||||
|
|
||||||
local HEADER_HEIGHT = 45
|
local HEADER_HEIGHT = 45
|
||||||
local HEADER_UNDERLINE_CAP = CAIRO_LINE_CAP_ROUND
|
local HEADER_UNDERLINE_CAP = CAIRO_LINE_CAP_ROUND
|
||||||
local HEADER_UNDERLINE_OFFSET = 26
|
local HEADER_UNDERLINE_OFFSET = 26
|
||||||
|
@ -103,13 +99,13 @@ return function(config)
|
||||||
return {
|
return {
|
||||||
family = f,
|
family = f,
|
||||||
size = size,
|
size = size,
|
||||||
weight = bold and CAIRO_FONT_WEIGHT_BOLD or CAIRO_FONT_WEIGHT_NORMAL,
|
weight = bold and CAIRO_font_family_WEIGHT_BOLD or CAIRO_font_family_WEIGHT_NORMAL,
|
||||||
slant = CAIRO_FONT_WEIGHT_NORMAL,
|
slant = CAIRO_font_family_WEIGHT_NORMAL,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local normal_font_spec = make_font_spec(FONT, NORMAL_FONT_SIZE, false)
|
local normal_font_spec = make_font_spec(font_family, font_sizes.normal, false)
|
||||||
local label_font_spec = make_font_spec(FONT, PLOT_LABEL_FONT_SIZE, false)
|
local label_font_spec = make_font_spec(font_family, font_sizes.plot_label, false)
|
||||||
|
|
||||||
local _text_row_style = function(x_align, color)
|
local _text_row_style = function(x_align, color)
|
||||||
return text.config(normal_font_spec, color, x_align, 'center')
|
return text.config(normal_font_spec, color, x_align, 'center')
|
||||||
|
@ -218,7 +214,7 @@ return function(config)
|
||||||
geom.make_point(x, y),
|
geom.make_point(x, y),
|
||||||
_text,
|
_text,
|
||||||
text.config(
|
text.config(
|
||||||
make_font_spec(FONT, HEADER_FONT_SIZE, true),
|
make_font_spec(font_family, font_sizes.header, true),
|
||||||
patterns.header,
|
patterns.header,
|
||||||
'left',
|
'left',
|
||||||
'top'
|
'top'
|
||||||
|
@ -629,7 +625,7 @@ return function(config)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- table
|
-- table
|
||||||
|
|
||||||
local default_table_font_spec = make_font_spec(FONT, TABLE_FONT_SIZE, false)
|
local default_table_font_spec = make_font_spec(font_family, font_sizes.table, false)
|
||||||
|
|
||||||
local default_table_config = function(label)
|
local default_table_config = function(label)
|
||||||
return tbl.config(
|
return tbl.config(
|
||||||
|
@ -673,6 +669,10 @@ return function(config)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.table_height = function(n)
|
||||||
|
return TABLE_VERT_PAD * 2 + TABLE_HEADER_PAD + 13 * n
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- panel
|
-- panel
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ return function(update_freq, config, common, width, point)
|
||||||
local PLOT_SECTION_BREAK = 22
|
local PLOT_SECTION_BREAK = 22
|
||||||
local PLOT_HEIGHT = 56
|
local PLOT_HEIGHT = 56
|
||||||
local TABLE_SECTION_BREAK = 20
|
local TABLE_SECTION_BREAK = 20
|
||||||
local TABLE_HEIGHT = 114
|
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
local __math_floor = math.floor
|
local __math_floor = math.floor
|
||||||
|
@ -141,8 +140,9 @@ return function(update_freq, config, common, width, point)
|
||||||
-- memory top table
|
-- memory top table
|
||||||
|
|
||||||
local mk_tbl = function(y)
|
local mk_tbl = function(y)
|
||||||
local NUM_ROWS = 5
|
local num_rows = config.table_rows
|
||||||
local TABLE_CONKY = pure.map_n(
|
local table_height = common.table_height(num_rows)
|
||||||
|
local table_conky = pure.map_n(
|
||||||
function(i)
|
function(i)
|
||||||
return {
|
return {
|
||||||
comm = '${top_mem name '..i..'}',
|
comm = '${top_mem name '..i..'}',
|
||||||
|
@ -150,25 +150,25 @@ return function(update_freq, config, common, width, point)
|
||||||
mem = '${top_mem mem '..i..'}',
|
mem = '${top_mem mem '..i..'}',
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
NUM_ROWS)
|
num_rows)
|
||||||
local obj = common.make_text_table(
|
local obj = common.make_text_table(
|
||||||
point.x,
|
point.x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
TABLE_HEIGHT,
|
table_height,
|
||||||
NUM_ROWS,
|
num_rows,
|
||||||
'Mem (%)'
|
'Mem (%)'
|
||||||
)
|
)
|
||||||
local update = function()
|
local update = function()
|
||||||
for r = 1, NUM_ROWS do
|
for r = 1, num_rows do
|
||||||
text_table.set(obj, 1, r, i_o.conky(TABLE_CONKY[r].comm, '(%S+)'))
|
text_table.set(obj, 1, r, i_o.conky(table_conky[r].comm, '(%S+)'))
|
||||||
text_table.set(obj, 2, r, i_o.conky(TABLE_CONKY[r].pid))
|
text_table.set(obj, 2, r, i_o.conky(table_conky[r].pid))
|
||||||
text_table.set(obj, 3, r, i_o.conky(TABLE_CONKY[r].mem))
|
text_table.set(obj, 3, r, i_o.conky(table_conky[r].mem))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return common.mk_acc(
|
||||||
width,
|
width,
|
||||||
TABLE_HEIGHT,
|
table_height,
|
||||||
update,
|
update,
|
||||||
pure.partial(text_table.draw_static, obj),
|
pure.partial(text_table.draw_static, obj),
|
||||||
pure.partial(text_table.draw_dynamic, obj)
|
pure.partial(text_table.draw_dynamic, obj)
|
||||||
|
@ -186,7 +186,7 @@ return function(update_freq, config, common, width, point)
|
||||||
top = {
|
top = {
|
||||||
{mk_stats, config.show_stats, PLOT_SECTION_BREAK},
|
{mk_stats, config.show_stats, PLOT_SECTION_BREAK},
|
||||||
{mk_plot, config.show_plot, TABLE_SECTION_BREAK},
|
{mk_plot, config.show_plot, TABLE_SECTION_BREAK},
|
||||||
{mk_tbl, config.show_table, 0},
|
{mk_tbl, config.table_rows > 0, 0},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,12 +10,12 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
local DIAL_INNER_RADIUS = 30
|
local DIAL_INNER_RADIUS = 30
|
||||||
local DIAL_OUTER_RADIUS = 42
|
local DIAL_OUTER_RADIUS = 42
|
||||||
local DIAL_THICKNESS = 5.5
|
local DIAL_THICKNESS = 5.5
|
||||||
|
local DIAL_SPACING = 20
|
||||||
local SEPARATOR_SPACING = 20
|
local SEPARATOR_SPACING = 20
|
||||||
local TEXT_SPACING = 22
|
local TEXT_SPACING = 22
|
||||||
local PLOT_SECTION_BREAK = 23
|
local PLOT_SECTION_BREAK = 23
|
||||||
local PLOT_HEIGHT = 56
|
local PLOT_HEIGHT = 56
|
||||||
local TABLE_SECTION_BREAK = 20
|
local TABLE_SECTION_BREAK = 20
|
||||||
local TABLE_HEIGHT = 114
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- processor state
|
-- processor state
|
||||||
|
@ -33,6 +33,22 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
local ncores = cpu.get_core_number()
|
local ncores = cpu.get_core_number()
|
||||||
local nthreads = ncpus / ncores
|
local nthreads = ncpus / ncores
|
||||||
|
|
||||||
|
local show_cores = false
|
||||||
|
|
||||||
|
if config.core_rows > 0 then
|
||||||
|
if math.fmod(ncores, config.core_rows) == 0 then
|
||||||
|
show_cores = true
|
||||||
|
else
|
||||||
|
print(
|
||||||
|
string.format(
|
||||||
|
'WARNING: could not evenly distribute %i cores over %i rows',
|
||||||
|
ncores,
|
||||||
|
config.core_rows
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local create_core = function(x, y)
|
local create_core = function(x, y)
|
||||||
return {
|
return {
|
||||||
loads = common.make_compound_dial(
|
loads = common.make_compound_dial(
|
||||||
|
@ -57,12 +73,23 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
|
|
||||||
local mk_cores = function(y)
|
local mk_cores = function(y)
|
||||||
local coretemp_paths = cpu.get_coretemp_paths()
|
local coretemp_paths = cpu.get_coretemp_paths()
|
||||||
|
local core_cols = ncores / config.core_rows
|
||||||
local cores = {}
|
local cores = {}
|
||||||
-- TODO what happens when the number of cores changes?
|
|
||||||
for c = 1, ncores do
|
for c = 1, ncores do
|
||||||
local dial_x = point.x + DIAL_OUTER_RADIUS +
|
local dial_x
|
||||||
(width - 2 * DIAL_OUTER_RADIUS) * (c - 1) / 3
|
local dial_y
|
||||||
local dial_y = y + DIAL_OUTER_RADIUS
|
if core_cols == 1 then
|
||||||
|
dial_x = point.x + width / 2
|
||||||
|
dial_y = y + DIAL_OUTER_RADIUS +
|
||||||
|
(2 * DIAL_OUTER_RADIUS + DIAL_SPACING) * (c - 1)
|
||||||
|
else
|
||||||
|
dial_x = point.x + config.core_padding + DIAL_OUTER_RADIUS +
|
||||||
|
(width - 2 * (DIAL_OUTER_RADIUS + config.core_padding))
|
||||||
|
* math.fmod(c - 1, core_cols) / (core_cols - 1)
|
||||||
|
dial_y = y + DIAL_OUTER_RADIUS +
|
||||||
|
(2 * DIAL_OUTER_RADIUS + DIAL_SPACING)
|
||||||
|
* math.floor((c - 1) / core_cols) / (core_cols - 1)
|
||||||
|
end
|
||||||
cores[c] = create_core(dial_x, dial_y)
|
cores[c] = create_core(dial_x, dial_y)
|
||||||
end
|
end
|
||||||
local update = function()
|
local update = function()
|
||||||
|
@ -92,7 +119,8 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
end
|
end
|
||||||
return common.mk_acc(
|
return common.mk_acc(
|
||||||
width,
|
width,
|
||||||
DIAL_OUTER_RADIUS * 2,
|
(DIAL_OUTER_RADIUS * 2 + DIAL_SPACING) * config.core_rows
|
||||||
|
- DIAL_SPACING,
|
||||||
update,
|
update,
|
||||||
static,
|
static,
|
||||||
dynamic
|
dynamic
|
||||||
|
@ -166,38 +194,36 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
-- cpu top table
|
-- cpu top table
|
||||||
|
|
||||||
local mk_tbl = function(y)
|
local mk_tbl = function(y)
|
||||||
local NUM_ROWS = 5
|
local num_rows = config.table_rows
|
||||||
local TABLE_CONKY = pure.map_n(
|
local table_height = common.table_height(num_rows)
|
||||||
|
local table_conky = pure.map_n(
|
||||||
function(i) return {pid = '${top pid '..i..'}', cpu = '${top cpu '..i..'}'} end,
|
function(i) return {pid = '${top pid '..i..'}', cpu = '${top cpu '..i..'}'} end,
|
||||||
NUM_ROWS
|
num_rows
|
||||||
)
|
)
|
||||||
local tbl = common.make_text_table(
|
local tbl = common.make_text_table(
|
||||||
point.x,
|
point.x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
TABLE_HEIGHT,
|
table_height,
|
||||||
NUM_ROWS,
|
num_rows,
|
||||||
'CPU (%)'
|
'CPU (%)'
|
||||||
)
|
)
|
||||||
local update = function(state_)
|
local update = function()
|
||||||
for r = 1, NUM_ROWS do
|
for r = 1, num_rows do
|
||||||
local pid = i_o.conky(TABLE_CONKY[r].pid, '(%d+)') -- may have leading spaces
|
local pid = i_o.conky(table_conky[r].pid, '(%d+)') -- may have leading spaces
|
||||||
if pid ~= '' then
|
if pid ~= '' then
|
||||||
text_table.set(tbl, 1, r, i_o.read_file('/proc/'..pid..'/comm', '(%C+)'))
|
text_table.set(tbl, 1, r, i_o.read_file('/proc/'..pid..'/comm', '(%C+)'))
|
||||||
text_table.set(tbl, 2, r, pid)
|
text_table.set(tbl, 2, r, pid)
|
||||||
text_table.set(tbl, 3, r, i_o.conky(TABLE_CONKY[r].cpu))
|
text_table.set(tbl, 3, r, i_o.conky(table_conky[r].cpu))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return state_
|
|
||||||
end
|
end
|
||||||
local static = pure.partial(text_table.draw_static, tbl)
|
|
||||||
local dynamic = pure.partial(text_table.draw_dynamic, tbl)
|
|
||||||
return common.mk_acc(
|
return common.mk_acc(
|
||||||
width,
|
width,
|
||||||
TABLE_HEIGHT,
|
table_height,
|
||||||
update,
|
update,
|
||||||
static,
|
pure.partial(text_table.draw_static, tbl),
|
||||||
dynamic
|
pure.partial(text_table.draw_dynamic, tbl)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -210,13 +236,13 @@ return function(update_freq, config, main_state, common, width, point)
|
||||||
width = width,
|
width = width,
|
||||||
set_state = update_state,
|
set_state = update_state,
|
||||||
top = {
|
top = {
|
||||||
{mk_cores, config.show_cores, TEXT_SPACING},
|
{mk_cores, show_cores, TEXT_SPACING},
|
||||||
{mk_hwp_freq, config.show_stats, SEPARATOR_SPACING},
|
{mk_hwp_freq, config.show_stats, SEPARATOR_SPACING},
|
||||||
},
|
},
|
||||||
common.mk_section(
|
common.mk_section(
|
||||||
SEPARATOR_SPACING,
|
SEPARATOR_SPACING,
|
||||||
{mk_load_plot, config.show_plot, TABLE_SECTION_BREAK},
|
{mk_load_plot, config.show_plot, TABLE_SECTION_BREAK},
|
||||||
{mk_tbl, config.show_table, 0}
|
{mk_tbl, config.table_rows > 0, 0}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
41
schema.yml
41
schema.yml
|
@ -49,7 +49,7 @@ properties:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
||||||
memory:
|
memory:
|
||||||
required: [show_stats, show_plot, show_table]
|
required: [show_stats, show_plot, table_rows]
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
show_stats:
|
show_stats:
|
||||||
|
@ -58,9 +58,10 @@ properties:
|
||||||
show_plot:
|
show_plot:
|
||||||
description: show the RAM utilization plot
|
description: show the RAM utilization plot
|
||||||
type: boolean
|
type: boolean
|
||||||
show_table:
|
table_rows: &table
|
||||||
description: show the memory process table
|
descrition: the number of rows in the table (0 for no table)
|
||||||
type: boolean
|
type: integer
|
||||||
|
minimum: 0
|
||||||
|
|
||||||
power:
|
power:
|
||||||
required: [battery, rapl_specs]
|
required: [battery, rapl_specs]
|
||||||
|
@ -85,21 +86,24 @@ properties:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
processor:
|
processor:
|
||||||
required: [show_cores, show_stats, show_plot, show_table]
|
required: [core_rows, show_stats, show_plot, table_rows]
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
show_cores:
|
core_rows:
|
||||||
description: show individual CPU cores
|
description: the number of rows over which to show discrete cores
|
||||||
type: boolean
|
type: integer
|
||||||
|
minimum: 0
|
||||||
|
core_padding:
|
||||||
|
description: horizontal padding to apply to the core layout
|
||||||
|
type: integer
|
||||||
|
minimum: 0
|
||||||
show_stats:
|
show_stats:
|
||||||
description: show frequency/HWP stats
|
description: show frequency/HWP stats
|
||||||
type: boolean
|
type: boolean
|
||||||
show_plot:
|
show_plot:
|
||||||
description: show CPU utilization plot
|
description: show CPU utilization plot
|
||||||
type: boolean
|
type: boolean
|
||||||
show_table:
|
table_rows: *table
|
||||||
description: show the CPU process table
|
|
||||||
type: boolean
|
|
||||||
|
|
||||||
readwrite:
|
readwrite:
|
||||||
required: [devices]
|
required: [devices]
|
||||||
|
@ -178,8 +182,21 @@ properties:
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
properties:
|
properties:
|
||||||
font:
|
font:
|
||||||
description: the font to use
|
required: [family, sizes]
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
family:
|
||||||
type: string
|
type: string
|
||||||
|
sizes:
|
||||||
|
required: [normal, plot_label, table, header]
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
normal: &font_size
|
||||||
|
type: integer
|
||||||
|
minimum: 5
|
||||||
|
plot_label: *font_size
|
||||||
|
table: *font_size
|
||||||
|
header: *font_size
|
||||||
patterns:
|
patterns:
|
||||||
required: [header, panel, text, border, plot, indicator]
|
required: [header, panel, text, border, plot, indicator]
|
||||||
additionalProperties: false
|
additionalProperties: false
|
||||||
|
|
Loading…
Reference in New Issue