From f24f5c1f4fb8bb16a689cf58f26c963c58c556e9 Mon Sep 17 00:00:00 2001 From: dollplayer2501 Date: Tue, 9 Jan 2024 13:49:55 +0900 Subject: [PATCH] #44 fixed --- angle_minus_five_degrees.lua | 4 +- config-sample.lua | 5 ++ config/text_detail.lua | 2 + includes/conky_parse.lua | 33 ++++++----- modules/text_detail.lua | 105 +++++++++++++++++++++++++++-------- 5 files changed, 113 insertions(+), 36 deletions(-) diff --git a/angle_minus_five_degrees.lua b/angle_minus_five_degrees.lua index d46ebb4..853eaa1 100644 --- a/angle_minus_five_degrees.lua +++ b/angle_minus_five_degrees.lua @@ -85,7 +85,7 @@ function conky_main() FONT_SIZE = 64, FONT_FACE = global_const.FONT_FACE_2_1, FONT_WEIGHT = CAIRO_FONT_WEIGHT_NORMAL, - MARGIN = 40, + MARGIN = 60, } TODAY_WIDTH['WIDTH'] = getting_text_width(cr_draw, @@ -396,6 +396,8 @@ function conky_main() global_config.filesystem.device, global_conky_parse, global_const.USAGE_LIMIT, -- display global ip address cfg.display_global_ip_address, + -- display swap + cfg.display_swap, -- position cfg.position_x, cfg.position_y, cfg.position_align, -- large font diff --git a/config-sample.lua b/config-sample.lua index d387cff..c67b062 100644 --- a/config-sample.lua +++ b/config-sample.lua @@ -126,5 +126,10 @@ function get_config() -- Device files subject to file writing/reading speeds device = '/dev/sda2', }, + + -- + -- Swap + -- + display_swap = true, } end diff --git a/config/text_detail.lua b/config/text_detail.lua index 968d420..b0337c3 100644 --- a/config/text_detail.lua +++ b/config/text_detail.lua @@ -6,6 +6,8 @@ function get_config_text_detail(_const, _config) return { -- display global ip address display_global_ip_address = _config.display_global_ip_address, + -- display swap + display_swap = _config.display_swap, -- position position_x = _const.CENTER_POSITION.THEME.X, diff --git a/includes/conky_parse.lua b/includes/conky_parse.lua index 68479e7..8dfdcf0 100644 --- a/includes/conky_parse.lua +++ b/includes/conky_parse.lua @@ -71,19 +71,26 @@ function get_conky_parse() diskio_read = conky_parse('${diskio_read '.. config.filesystem.device .. '}'), top = { - name1 = conky_parse("${top name 1}"), - name2 = conky_parse("${top name 2}"), - name3 = conky_parse("${top name 3}"), - name4 = conky_parse("${top name 4}"), - name5 = conky_parse("${top name 5}"), - name6 = conky_parse("${top name 6}"), - - cpu1 = conky_parse("${top cpu 1}"), - cpu2 = conky_parse("${top cpu 2}"), - cpu3 = conky_parse("${top cpu 3}"), - cpu4 = conky_parse("${top cpu 4}"), - cpu5 = conky_parse("${top cpu 5}"), - cpu6 = conky_parse("${top cpu 6}"), + name1 = conky_parse('${top name 1}'), + name2 = conky_parse('${top name 2}'), + name3 = conky_parse('${top name 3}'), + name4 = conky_parse('${top name 4}'), + name5 = conky_parse('${top name 5}'), + name6 = conky_parse('${top name 6}'), + + cpu1 = conky_parse('${top cpu 1}'), + cpu2 = conky_parse('${top cpu 2}'), + cpu3 = conky_parse('${top cpu 3}'), + cpu4 = conky_parse('${top cpu 4}'), + cpu5 = conky_parse('${top cpu 5}'), + cpu6 = conky_parse('${top cpu 6}'), + }, + + swap = { + swap = conky_parse('${swap}'), + swapfree = conky_parse('${swapfree}'), + swapmax = conky_parse('${swapmax}'), + swapperc = conky_parse('${swapperc}'), }, conky_version = triming(conky_parse('${conky_version}')), diff --git a/modules/text_detail.lua b/modules/text_detail.lua index 507dd68..98d54c7 100644 --- a/modules/text_detail.lua +++ b/modules/text_detail.lua @@ -7,6 +7,8 @@ function drawing_text_detail(_context, _conky_parse_updates, _const_disk_device, _conky_parse, _usage_limit, -- display global ip address _display_global_ip_address, + -- display swap + _display_swap, -- position _position_x, _position_y, _position_align, -- large font @@ -304,68 +306,126 @@ function drawing_text_detail(_context, _conky_parse_updates, -- - -- Memory Usage + -- Memory and Swap Usage -- - idx = idx + 1 - _drawing_text_with_properties_align_right(_context, _position_align, - _position_x + _adjust_x_normal, - _position_y + _adjust_y_normal + (_gap_y_normal * idx), - _font_size_normal, { + tmp_array = { + { + _text = string.format('%s', + 'Memory is' + ), + _font_face = _font_face_normal, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _color_detail.body_normal + }, { + _text = string.format(' %s', + _conky_parse.mem + ), + _font_face = _font_face_large, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _usage_limit.MEMORY < tonumber(_conky_parse.memperc) + and _color_detail.body_strike or _color_detail.body_normal + }, { + _text = string.format('%s', + '/' + ), + _font_face = _font_face_normal, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _color_detail.body_normal + }, { + _text = string.format('%s', + _conky_parse.memmax + ), + _font_face = _font_face_large, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _usage_limit.MEMORY < tonumber(_conky_parse.memperc) + and _color_detail.body_strike or _color_detail.body_normal + }, { + _text = string.format('%s', + ',' + ), + _font_face = _font_face_normal, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _color_detail.body_normal + }, { + _text = string.format(' %s%%', + _conky_parse.memperc + ), + _font_face = _font_face_large, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _usage_limit.MEMORY < tonumber(_conky_parse.memperc) + and _color_detail.body_strike or _color_detail.body_normal + }, { + _text = string.format(' %s', + 'used' + ), + _font_face = _font_face_normal, + _font_weight = CAIRO_FONT_WEIGHT_NORMAL, + _font_color = _color_detail.body_normal + } + } + + if true == _display_swap then + + tmp_array = appendding_array_table(tmp_array, { { _text = string.format('%s', - 'Memory is' + ', Swap is' ), _font_face = _font_face_normal, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, _font_color = _color_detail.body_normal }, { _text = string.format(' %s', - _conky_parse.mem + _conky_parse.swap.swap ), _font_face = _font_face_large, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, - _font_color = _usage_limit.MEMORY < tonumber(_conky_parse.memperc) - and _color_detail.body_strike or _color_detail.body_normal + _font_color = _color_detail.body_normal }, { _text = string.format('%s', - '/' + ',' ), _font_face = _font_face_normal, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, _font_color = _color_detail.body_normal }, { - _text = string.format('%s', - _conky_parse.memmax + _text = string.format(' %s%%', + _conky_parse.swap.swapperc ), _font_face = _font_face_large, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, - _font_color = _usage_limit.MEMORY < tonumber(_conky_parse.memperc) - and _color_detail.body_strike or _color_detail.body_normal + _font_color = _color_detail.body_normal }, { - _text = string.format('%s', - ',' + _text = string.format(' %s', + 'used,' ), _font_face = _font_face_normal, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, _font_color = _color_detail.body_normal }, { - _text = string.format(' %s%%', - _conky_parse.memperc + _text = string.format(' %s', + _conky_parse.swap.swapfree ), _font_face = _font_face_large, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, - _font_color = _usage_limit.MEMORY < tonumber(_conky_parse.memperc) - and _color_detail.body_strike or _color_detail.body_normal + _font_color = _color_detail.body_normal }, { _text = string.format(' %s', - 'used' + 'free' ), _font_face = _font_face_normal, _font_weight = CAIRO_FONT_WEIGHT_NORMAL, _font_color = _color_detail.body_normal } }) + end + + idx = idx + 1 + _drawing_text_with_properties_align_right(_context, _position_align, + _position_x + _adjust_x_normal, + _position_y + _adjust_y_normal + (_gap_y_normal * idx), + _font_size_normal, tmp_array) -- @@ -494,6 +554,7 @@ function drawing_text_detail(_context, _conky_parse_updates, _position_y + _adjust_y_normal + (_gap_y_normal * idx), _font_size_normal, tmp_array) + -- -- Disk info, Strage, Disk I/O --