ENH update to lua 5.3

This commit is contained in:
Nathan Dwarshuis 2019-09-01 15:34:10 -04:00
parent 7125292168
commit d1c31f1f38
5 changed files with 50 additions and 47 deletions

View File

@ -148,7 +148,7 @@ local update = function(cr)
local used_percent = (MEM_TOTAL_KB - memfree_kb - cached_kb - buffers_kb - slab_reclaimable_kb) / MEM_TOTAL_KB local used_percent = (MEM_TOTAL_KB - memfree_kb - cached_kb - buffers_kb - slab_reclaimable_kb) / MEM_TOTAL_KB
Dial.set(dial, used_percent) Dial.set(dial, used_percent)
CriticalText.set(total_used, cr, Util.round(used_percent * 100)) CriticalText.set(total_used, cr, Util.round_to_string(used_percent * 100))
local cache_theta = (DIAL_THETA_0 - DIAL_THETA_1) / MEM_TOTAL_KB * memfree_kb + DIAL_THETA_1 local cache_theta = (DIAL_THETA_0 - DIAL_THETA_1) / MEM_TOTAL_KB * memfree_kb + DIAL_THETA_1
__cairo_path_destroy(cache_arc.path) __cairo_path_destroy(cache_arc.path)

View File

@ -9,6 +9,8 @@ local LabelPlot = require 'LabelPlot'
local Table = require 'Table' local Table = require 'Table'
local Util = require 'Util' local Util = require 'Util'
local __string_format = string.format
local CORETEMP_PATH = '/sys/devices/platform/coretemp.0/hwmon/hwmon%i/%s' local CORETEMP_PATH = '/sys/devices/platform/coretemp.0/hwmon/hwmon%i/%s'
local NUM_PHYSICAL_CORES = 4 local NUM_PHYSICAL_CORES = 4
@ -28,7 +30,6 @@ local _MODULE_Y_ = 614
local _DIAL_INNER_RADIUS_ = 30 local _DIAL_INNER_RADIUS_ = 30
local _DIAL_OUTER_RADIUS_ = 42 local _DIAL_OUTER_RADIUS_ = 42
local _DIAL_SPACING_ = 1 local _DIAL_SPACING_ = 1
local _TEXT_Y_OFFSET_ = 15
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
@ -201,34 +202,37 @@ local update = function(cr)
freq_sum = freq_sum + Util.conky_numeric(conky_freqs[t]) freq_sum = freq_sum + Util.conky_numeric(conky_freqs[t])
end end
CriticalText.set(core.coretemp_text, cr, Util.round(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')
--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, (char_count(process_glob, 'R') - 1)..' | '.. Text.set(process.value, cr,
char_count(process_glob, 'S')..' | '.. __string_format('%s | %s | %s | %s | %s',
char_count(process_glob, 'D')..' | '.. (char_count(process_glob, 'R') - 1),
char_count(process_glob, 'T')..' | '.. char_count(process_glob, 'S'),
char_count(process_glob, 'Z')) char_count(process_glob, 'D'),
char_count(process_glob, 'T'),
char_count(process_glob, 'Z')))
Text.set(ave_freq.value, cr, Util.round(freq_sum / NUM_PHYSICAL_CORES / NUM_THREADS_PER_CORE) .. ' MHz') Text.set(ave_freq.value, cr, Util.round_to_string(freq_sum / NUM_PHYSICAL_CORES / NUM_THREADS_PER_CORE) .. ' MHz')
local load_percent = Util.round(load_sum / NUM_PHYSICAL_CORES / NUM_THREADS_PER_CORE, 2) local load_percent = Util.round(load_sum / NUM_PHYSICAL_CORES / NUM_THREADS_PER_CORE, 2)
CriticalText.set(total_load.value, cr, load_percent * 100) CriticalText.set(total_load.value, cr,
Util.round_to_string(load_percent * 100))
LabelPlot.update(plot, load_percent) LabelPlot.update(plot, load_percent)
for r = 1, NUM_ROWS do for r = 1, NUM_ROWS do
local pid = conky(TABLE_CONKY[r].pid, '(%S+)') local pid = conky(TABLE_CONKY[r].pid, '(%S+)')
if pid ~= '' then if pid ~= '' then
local cpu = conky(TABLE_CONKY[r].cpu) local cpu = conky(TABLE_CONKY[r].cpu)
local comm = Util.read_file('/proc/'..pid..'/stat', '%d+%s+%((.+)%)') local comm = Util.read_file('/proc/'..pid..'/stat', '%d+%s+%((.+)%)')
Table.set(tbl, cr, 1, r, comm) Table.set(tbl, cr, 1, r, comm)
Table.set(tbl, cr, 2, r, pid) Table.set(tbl, cr, 2, r, pid)
Table.set(tbl, cr, 3, r, cpu) Table.set(tbl, cr, 3, r, cpu)
end end
end end
end end

View File

@ -101,5 +101,4 @@ M.TRANSPARENT_BLACK = Color.init{hex_rgba = 0x000000, alpha = 0.7}
M = Util.set_finalizer(M, function() print('Cleaning up Patterns.lua') end) M = Util.set_finalizer(M, function() print('Cleaning up Patterns.lua') end)
return M return M