rename json and util to follow naming conventions
This commit is contained in:
parent
3412fbbd62
commit
7fecbdab4a
2
core
2
core
|
@ -1 +1 @@
|
||||||
Subproject commit bc98d64370d9fcd164d73514976238e806d862d1
|
Subproject commit cf0fe0434d2cd48f9f255c5371f280c1cbe07f1f
|
|
@ -3,8 +3,7 @@ local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local TextColumn = require 'TextColumn'
|
local TextColumn = require 'TextColumn'
|
||||||
local CompoundBar = require 'CompoundBar'
|
local CompoundBar = require 'CompoundBar'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
|
|
||||||
|
@ -50,7 +49,6 @@ local bars = Widget.CompoundBar{
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget = nil
|
Widget = nil
|
||||||
Patterns = nil
|
|
||||||
|
|
||||||
_SPACING_ = nil
|
_SPACING_ = nil
|
||||||
_BAR_PAD_ = nil
|
_BAR_PAD_ = nil
|
||||||
|
@ -58,7 +56,7 @@ _FS_PATHS_ = nil
|
||||||
|
|
||||||
local update = function(cr)
|
local update = function(cr)
|
||||||
for i = 1, FS_NUM do
|
for i = 1, FS_NUM do
|
||||||
local percent = util.conky_numeric(conky_used_perc[i])
|
local percent = Util.conky_numeric(conky_used_perc[i])
|
||||||
CompoundBar.set(bars, i, percent * 0.01)
|
CompoundBar.set(bars, i, percent * 0.01)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ local Text = require 'Text'
|
||||||
local TextColumn = require 'TextColumn'
|
local TextColumn = require 'TextColumn'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local LabelPlot = require 'LabelPlot'
|
local LabelPlot = require 'LabelPlot'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local __tonumber = tonumber
|
local __tonumber = tonumber
|
||||||
|
@ -228,7 +228,7 @@ end
|
||||||
|
|
||||||
local update = function(cr)
|
local update = function(cr)
|
||||||
-- check if bbswitch is on
|
-- check if bbswitch is on
|
||||||
if util.read_file('/proc/acpi/bbswitch', '.+%s+(%u+)') == 'ON' then
|
if Util.read_file('/proc/acpi/bbswitch', '.+%s+(%u+)') == 'ON' then
|
||||||
|
|
||||||
-- bbswitch might be on, but only because conky is constantly querying
|
-- bbswitch might be on, but only because conky is constantly querying
|
||||||
-- it and there appears to be some lag between closing all optirun
|
-- it and there appears to be some lag between closing all optirun
|
||||||
|
@ -236,12 +236,12 @@ local update = function(cr)
|
||||||
-- no optirun processes, we call this "Mixed." In this case we don't
|
-- no optirun processes, we call this "Mixed." In this case we don't
|
||||||
-- check anything (to allow bbswitch to actually switch off) and set all
|
-- check anything (to allow bbswitch to actually switch off) and set all
|
||||||
-- values to N/A and 0.
|
-- values to N/A and 0.
|
||||||
if __string_find(util.execute_cmd('ps -A -o comm'), 'optirun') == nil then
|
if __string_find(Util.execute_cmd('ps -A -o comm'), 'optirun') == nil then
|
||||||
Text.set(status.value, cr, 'Mixed')
|
Text.set(status.value, cr, 'Mixed')
|
||||||
nvidia_off(cr)
|
nvidia_off(cr)
|
||||||
else
|
else
|
||||||
Text.set(status.value, cr, 'On')
|
Text.set(status.value, cr, 'On')
|
||||||
local nvidia_settings_glob = util.execute_cmd(NV_QUERY)
|
local nvidia_settings_glob = Util.execute_cmd(NV_QUERY)
|
||||||
|
|
||||||
local used_memory, total_memory, temp_reading, gpu_frequency,
|
local used_memory, total_memory, temp_reading, gpu_frequency,
|
||||||
memory_frequency, gpu_utilization, vid_utilization,
|
memory_frequency, gpu_utilization, vid_utilization,
|
||||||
|
@ -259,7 +259,7 @@ local update = function(cr)
|
||||||
local percent_used_memory = used_memory / total_memory
|
local percent_used_memory = used_memory / total_memory
|
||||||
|
|
||||||
Text.set(gpu_util.value, cr, gpu_utilization..'%')
|
Text.set(gpu_util.value, cr, gpu_utilization..'%')
|
||||||
Text.set(mem_util.value, cr, util.round(percent_used_memory * 100)..'%')
|
Text.set(mem_util.value, cr, Util.round(percent_used_memory * 100)..'%')
|
||||||
Text.set(vid_util.value, cr, vid_utilization..'%')
|
Text.set(vid_util.value, cr, vid_utilization..'%')
|
||||||
|
|
||||||
LabelPlot.update(gpu_util.plot, gpu_utilization * 0.01)
|
LabelPlot.update(gpu_util.plot, gpu_utilization * 0.01)
|
||||||
|
|
|
@ -7,7 +7,7 @@ local TextColumn = require 'TextColumn'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local LabelPlot = require 'LabelPlot'
|
local LabelPlot = require 'LabelPlot'
|
||||||
local Table = require 'Table'
|
local Table = require 'Table'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
|
@ -24,7 +24,7 @@ local _PLOT_HEIGHT_ = 56
|
||||||
local _TABLE_SECTION_BREAK_ = 20
|
local _TABLE_SECTION_BREAK_ = 20
|
||||||
local _TABLE_HEIGHT_ = 114
|
local _TABLE_HEIGHT_ = 114
|
||||||
|
|
||||||
local MEM_TOTAL_KB = tonumber(util.read_file('/proc/meminfo', '^MemTotal:%s+(%d+)'))
|
local MEM_TOTAL_KB = tonumber(Util.read_file('/proc/meminfo', '^MemTotal:%s+(%d+)'))
|
||||||
|
|
||||||
local MEMINFO_REGEX = '\nMemFree:%s+(%d+).+'..
|
local MEMINFO_REGEX = '\nMemFree:%s+(%d+).+'..
|
||||||
'\nBuffers:%s+(%d+).+'..
|
'\nBuffers:%s+(%d+).+'..
|
||||||
|
@ -149,29 +149,29 @@ local update = function(cr)
|
||||||
-- see source for the 'free' command (sysinfo.c) for formulas
|
-- see source for the 'free' command (sysinfo.c) for formulas
|
||||||
|
|
||||||
local memfree_kb, buffers_kb, cached_kb, swap_total_kb, swap_free_kb,
|
local memfree_kb, buffers_kb, cached_kb, swap_total_kb, swap_free_kb,
|
||||||
slab_reclaimable_kb = __string_match(util.read_file('/proc/meminfo'), MEMINFO_REGEX)
|
slab_reclaimable_kb = __string_match(Util.read_file('/proc/meminfo'), MEMINFO_REGEX)
|
||||||
|
|
||||||
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(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)
|
||||||
cache_arc.path = Arc.create_path(cr, DIAL_X, DIAL_Y, DIAL_RADIUS, dial.dial_angle, cache_theta)
|
cache_arc.path = Arc.create_path(cr, DIAL_X, DIAL_Y, DIAL_RADIUS, dial.dial_angle, cache_theta)
|
||||||
|
|
||||||
CriticalText.set(swap.percent, cr, util.precision_round_to_string(
|
CriticalText.set(swap.percent, cr, Util.precision_round_to_string(
|
||||||
(swap_total_kb - swap_free_kb) / swap_total_kb * 100))
|
(swap_total_kb - swap_free_kb) / swap_total_kb * 100))
|
||||||
|
|
||||||
local _percents = cache.percents
|
local _percents = cache.percents
|
||||||
|
|
||||||
TextColumn.set(_percents, cr, 1, util.precision_round_to_string(
|
TextColumn.set(_percents, cr, 1, Util.precision_round_to_string(
|
||||||
cached_kb / MEM_TOTAL_KB * 100))
|
cached_kb / MEM_TOTAL_KB * 100))
|
||||||
|
|
||||||
TextColumn.set(_percents, cr, 2, util.precision_round_to_string(
|
TextColumn.set(_percents, cr, 2, Util.precision_round_to_string(
|
||||||
buffers_kb / MEM_TOTAL_KB * 100))
|
buffers_kb / MEM_TOTAL_KB * 100))
|
||||||
|
|
||||||
TextColumn.set(_percents, cr, 3, util.precision_round_to_string(
|
TextColumn.set(_percents, cr, 3, Util.precision_round_to_string(
|
||||||
slab_reclaimable_kb / MEM_TOTAL_KB * 100))
|
slab_reclaimable_kb / MEM_TOTAL_KB * 100))
|
||||||
|
|
||||||
LabelPlot.update(plot, used_percent)
|
LabelPlot.update(plot, used_percent)
|
||||||
|
@ -179,7 +179,7 @@ local update = function(cr)
|
||||||
for c = 1, 3 do
|
for c = 1, 3 do
|
||||||
local column = TABLE_CONKY[c]
|
local column = TABLE_CONKY[c]
|
||||||
for r = 1, NUM_ROWS do
|
for r = 1, NUM_ROWS do
|
||||||
Table.set(tbl, cr, c, r, util.conky(column[r], '(%S+)'))
|
Table.set(tbl, cr, c, r, Util.conky(column[r], '(%S+)'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ local Widget = require 'Widget'
|
||||||
local Text = require 'Text'
|
local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local ScalePlot = require 'ScalePlot'
|
local ScalePlot = require 'ScalePlot'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local __string_gmatch = string.gmatch
|
local __string_gmatch = string.gmatch
|
||||||
|
@ -11,13 +11,13 @@ local _PLOT_SEC_BREAK_ = 20
|
||||||
local _PLOT_HEIGHT_ = 56
|
local _PLOT_HEIGHT_ = 56
|
||||||
|
|
||||||
local network_label_function = function(bytes)
|
local network_label_function = function(bytes)
|
||||||
local new_unit = util.get_unit(bytes)
|
local new_unit = Util.get_unit(bytes)
|
||||||
|
|
||||||
local converted = util.convert_bytes(bytes, 'B', new_unit)
|
local converted = Util.convert_bytes(bytes, 'B', new_unit)
|
||||||
local precision = 0
|
local precision = 0
|
||||||
if converted < 10 then precision = 1 end
|
if converted < 10 then precision = 1 end
|
||||||
|
|
||||||
return util.round_to_string(converted, precision)..' '..new_unit..'/s'
|
return Util.round_to_string(converted, precision)..' '..new_unit..'/s'
|
||||||
end
|
end
|
||||||
|
|
||||||
local header = Widget.Header{
|
local header = Widget.Header{
|
||||||
|
@ -81,7 +81,7 @@ local update = function(cr, update_frequency)
|
||||||
local rx_delta, tx_delta
|
local rx_delta, tx_delta
|
||||||
|
|
||||||
-- iterate through the route file and filter on interfaces that are gateways (flag = 0003)
|
-- iterate through the route file and filter on interfaces that are gateways (flag = 0003)
|
||||||
local iterator = __string_gmatch(util.read_file('/proc/net/route'),
|
local iterator = __string_gmatch(Util.read_file('/proc/net/route'),
|
||||||
'(%w+)%s+%w+%s+%w+%s+0003%s+')
|
'(%w+)%s+%w+%s+%w+%s+0003%s+')
|
||||||
|
|
||||||
for interface in iterator do
|
for interface in iterator do
|
||||||
|
@ -94,14 +94,14 @@ local update = function(cr, update_frequency)
|
||||||
interface_counters = {
|
interface_counters = {
|
||||||
rx_path = rx_path,
|
rx_path = rx_path,
|
||||||
tx_path = tx_path,
|
tx_path = tx_path,
|
||||||
prev_rx_byte_cnt = util.read_file(rx_path, nil, '*n'),
|
prev_rx_byte_cnt = Util.read_file(rx_path, nil, '*n'),
|
||||||
prev_tx_byte_cnt = util.read_file(tx_path, nil, '*n'),
|
prev_tx_byte_cnt = Util.read_file(tx_path, nil, '*n'),
|
||||||
}
|
}
|
||||||
interface_counters_tbl[interface] = interface_counters
|
interface_counters_tbl[interface] = interface_counters
|
||||||
end
|
end
|
||||||
|
|
||||||
local rx_byte_cnt = util.read_file(interface_counters.rx_path, nil, '*n')
|
local rx_byte_cnt = Util.read_file(interface_counters.rx_path, nil, '*n')
|
||||||
local tx_byte_cnt = util.read_file(interface_counters.tx_path, nil, '*n')
|
local tx_byte_cnt = Util.read_file(interface_counters.tx_path, nil, '*n')
|
||||||
|
|
||||||
rx_delta = rx_byte_cnt - interface_counters.prev_rx_byte_cnt
|
rx_delta = rx_byte_cnt - interface_counters.prev_rx_byte_cnt
|
||||||
tx_delta = tx_byte_cnt - interface_counters.prev_tx_byte_cnt
|
tx_delta = tx_byte_cnt - interface_counters.prev_tx_byte_cnt
|
||||||
|
@ -114,14 +114,14 @@ local update = function(cr, update_frequency)
|
||||||
if tx_delta > 0 then uspeed = uspeed + tx_delta * update_frequency end
|
if tx_delta > 0 then uspeed = uspeed + tx_delta * update_frequency end
|
||||||
end
|
end
|
||||||
|
|
||||||
local dspeed_unit = util.get_unit(dspeed)
|
local dspeed_unit = Util.get_unit(dspeed)
|
||||||
local uspeed_unit = util.get_unit(uspeed)
|
local uspeed_unit = Util.get_unit(uspeed)
|
||||||
|
|
||||||
dnload.speed.append_end = ' '..dspeed_unit..'/s'
|
dnload.speed.append_end = ' '..dspeed_unit..'/s'
|
||||||
upload.speed.append_end = ' '..uspeed_unit..'/s'
|
upload.speed.append_end = ' '..uspeed_unit..'/s'
|
||||||
|
|
||||||
Text.set(dnload.speed, cr, util.precision_convert_bytes(dspeed, 'B', dspeed_unit, 3))
|
Text.set(dnload.speed, cr, Util.precision_convert_bytes(dspeed, 'B', dspeed_unit, 3))
|
||||||
Text.set(upload.speed, cr, util.precision_convert_bytes(uspeed, 'B', uspeed_unit, 3))
|
Text.set(upload.speed, cr, Util.precision_convert_bytes(uspeed, 'B', uspeed_unit, 3))
|
||||||
|
|
||||||
ScalePlot.update(dnload.plot, cr, dspeed)
|
ScalePlot.update(dnload.plot, cr, dspeed)
|
||||||
ScalePlot.update(upload.plot, cr, uspeed)
|
ScalePlot.update(upload.plot, cr, uspeed)
|
||||||
|
|
|
@ -2,7 +2,7 @@ local Widget = require 'Widget'
|
||||||
local Text = require 'Text'
|
local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local TextColumn = require 'TextColumn'
|
local TextColumn = require 'TextColumn'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local PACMAN_TABLE = {
|
local PACMAN_TABLE = {
|
||||||
|
@ -47,7 +47,7 @@ _TEXT_SPACING_ = nil
|
||||||
|
|
||||||
local update = function(cr)
|
local update = function(cr)
|
||||||
for i, cmd in pairs(PACMAN_TABLE) do
|
for i, cmd in pairs(PACMAN_TABLE) do
|
||||||
TextColumn.set(info, cr, i, util.line_count(util.execute_cmd(cmd)))
|
TextColumn.set(info, cr, i, Util.line_count(Util.execute_cmd(cmd)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ local Text = require 'Text'
|
||||||
local TextColumn = require 'TextColumn'
|
local TextColumn = require 'TextColumn'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local ScalePlot = require 'ScalePlot'
|
local ScalePlot = require 'ScalePlot'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local _MODULE_Y_ = 328
|
local _MODULE_Y_ = 328
|
||||||
|
@ -135,30 +135,30 @@ local CORE_PATH = '/sys/class/powercap/intel-rapl:0:0/energy_uj'
|
||||||
local IGPU_PATH = '/sys/class/powercap/intel-rapl:0:1/energy_uj'
|
local IGPU_PATH = '/sys/class/powercap/intel-rapl:0:1/energy_uj'
|
||||||
local DRAM_PATH = '/sys/class/powercap/intel-rapl:0:2/energy_uj'
|
local DRAM_PATH = '/sys/class/powercap/intel-rapl:0:2/energy_uj'
|
||||||
|
|
||||||
local prev_pkg0_uj_cnt = util.read_file(PKG0_PATH, nil, '*n')
|
local prev_pkg0_uj_cnt = Util.read_file(PKG0_PATH, nil, '*n')
|
||||||
local prev_core_uj_cnt = util.read_file(CORE_PATH, nil, '*n')
|
local prev_core_uj_cnt = Util.read_file(CORE_PATH, nil, '*n')
|
||||||
local prev_igpu_uj_cnt = util.read_file(IGPU_PATH, nil, '*n')
|
local prev_igpu_uj_cnt = Util.read_file(IGPU_PATH, nil, '*n')
|
||||||
local prev_dram_uj_cnt = util.read_file(DRAM_PATH, nil, '*n')
|
local prev_dram_uj_cnt = Util.read_file(DRAM_PATH, nil, '*n')
|
||||||
|
|
||||||
local update = function(cr, update_frequency, is_using_ac)
|
local update = function(cr, update_frequency, is_using_ac)
|
||||||
local pkg0_uj_cnt = util.read_file(PKG0_PATH, nil, '*n')
|
local pkg0_uj_cnt = Util.read_file(PKG0_PATH, nil, '*n')
|
||||||
local core_uj_cnt = util.read_file(CORE_PATH, nil, '*n')
|
local core_uj_cnt = Util.read_file(CORE_PATH, nil, '*n')
|
||||||
local igpu_uj_cnt = util.read_file(IGPU_PATH, nil, '*n')
|
local igpu_uj_cnt = Util.read_file(IGPU_PATH, nil, '*n')
|
||||||
local dram_uj_cnt = util.read_file(DRAM_PATH, nil, '*n')
|
local dram_uj_cnt = Util.read_file(DRAM_PATH, nil, '*n')
|
||||||
|
|
||||||
TextColumn.set(pp01.values, cr, 1, util.precision_round_to_string(
|
TextColumn.set(pp01.values, cr, 1, Util.precision_round_to_string(
|
||||||
calculate_power(cr, prev_core_uj_cnt, core_uj_cnt, update_frequency), 3))
|
calculate_power(cr, prev_core_uj_cnt, core_uj_cnt, update_frequency), 3))
|
||||||
|
|
||||||
TextColumn.set(pp01.values, cr, 2, util.precision_round_to_string(
|
TextColumn.set(pp01.values, cr, 2, Util.precision_round_to_string(
|
||||||
calculate_power(cr, prev_igpu_uj_cnt, igpu_uj_cnt, update_frequency), 3))
|
calculate_power(cr, prev_igpu_uj_cnt, igpu_uj_cnt, update_frequency), 3))
|
||||||
|
|
||||||
local pkg0_power = calculate_power(cr, prev_pkg0_uj_cnt, pkg0_uj_cnt, update_frequency)
|
local pkg0_power = calculate_power(cr, prev_pkg0_uj_cnt, pkg0_uj_cnt, update_frequency)
|
||||||
local dram_power = calculate_power(cr, prev_dram_uj_cnt, dram_uj_cnt, update_frequency)
|
local dram_power = calculate_power(cr, prev_dram_uj_cnt, dram_uj_cnt, update_frequency)
|
||||||
|
|
||||||
Text.set(pkg0.value, cr, util.precision_round_to_string(pkg0_power, 3))
|
Text.set(pkg0.value, cr, Util.precision_round_to_string(pkg0_power, 3))
|
||||||
ScalePlot.update(pkg0.plot, cr, pkg0_power)
|
ScalePlot.update(pkg0.plot, cr, pkg0_power)
|
||||||
|
|
||||||
Text.set(dram.value, cr, util.precision_round_to_string(dram_power, 3))
|
Text.set(dram.value, cr, Util.precision_round_to_string(dram_power, 3))
|
||||||
ScalePlot.update(dram.plot, cr, dram_power)
|
ScalePlot.update(dram.plot, cr, dram_power)
|
||||||
|
|
||||||
prev_pkg0_uj_cnt = pkg0_uj_cnt
|
prev_pkg0_uj_cnt = pkg0_uj_cnt
|
||||||
|
@ -170,11 +170,11 @@ local update = function(cr, update_frequency, is_using_ac)
|
||||||
Text.set(battery_draw.value, cr, 'A/C')
|
Text.set(battery_draw.value, cr, 'A/C')
|
||||||
ScalePlot.update(battery_draw.plot, cr, 0)
|
ScalePlot.update(battery_draw.plot, cr, 0)
|
||||||
else
|
else
|
||||||
local current = util.read_file('/sys/class/power_supply/BAT0/current_now', nil, '*n')
|
local current = Util.read_file('/sys/class/power_supply/BAT0/current_now', nil, '*n')
|
||||||
local voltage = util.read_file('/sys/class/power_supply/BAT0/voltage_now', nil, '*n')
|
local voltage = Util.read_file('/sys/class/power_supply/BAT0/voltage_now', nil, '*n')
|
||||||
local power = current * voltage * 0.000000000001
|
local power = current * voltage * 0.000000000001
|
||||||
|
|
||||||
Text.set(battery_draw.value, cr, util.precision_round_to_string(power, 3)..' W')
|
Text.set(battery_draw.value, cr, Util.precision_round_to_string(power, 3)..' W')
|
||||||
ScalePlot.update(battery_draw.plot, cr, power)
|
ScalePlot.update(battery_draw.plot, cr, power)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local LabelPlot = require 'LabelPlot'
|
local LabelPlot = require 'LabelPlot'
|
||||||
local Table = require 'Table'
|
local Table = require 'Table'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local CORETEMP_PATH = '/sys/devices/platform/coretemp.0/hwmon/hwmon%i/%s'
|
local CORETEMP_PATH = '/sys/devices/platform/coretemp.0/hwmon/hwmon%i/%s'
|
||||||
|
@ -38,13 +38,13 @@ local _create_core_ = function(cores, id, x, y)
|
||||||
local conky_threads = {}
|
local conky_threads = {}
|
||||||
|
|
||||||
for c = 0, NUM_PHYSICAL_CORES * NUM_THREADS_PER_CORE - 1 do
|
for c = 0, NUM_PHYSICAL_CORES * NUM_THREADS_PER_CORE - 1 do
|
||||||
if util.read_file('/sys/devices/system/cpu/cpu'..c..'/topology/core_id', nil, '*n') == id then
|
if Util.read_file('/sys/devices/system/cpu/cpu'..c..'/topology/core_id', nil, '*n') == id then
|
||||||
table.insert(conky_threads, '${cpu cpu'..c..'}')
|
table.insert(conky_threads, '${cpu cpu'..c..'}')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local hwmon_index = -1
|
local hwmon_index = -1
|
||||||
while util.read_file(string.format(CORETEMP_PATH, hwmon_index, 'name'), nil, '*l') ~= 'coretemp' do
|
while Util.read_file(string.format(CORETEMP_PATH, hwmon_index, 'name'), nil, '*l') ~= 'coretemp' do
|
||||||
hwmon_index = hwmon_index + 1
|
hwmon_index = hwmon_index + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -159,8 +159,8 @@ local tbl = Widget.Table{
|
||||||
}
|
}
|
||||||
|
|
||||||
local update = function(cr)
|
local update = function(cr)
|
||||||
local conky = util.conky
|
local conky = Util.conky
|
||||||
local char_count = util.char_count
|
local char_count = Util.char_count
|
||||||
|
|
||||||
local sum = 0
|
local sum = 0
|
||||||
for c = 1, NUM_PHYSICAL_CORES do
|
for c = 1, NUM_PHYSICAL_CORES do
|
||||||
|
@ -168,15 +168,15 @@ local update = function(cr)
|
||||||
|
|
||||||
local conky_threads = core.conky_threads
|
local conky_threads = core.conky_threads
|
||||||
for t = 1, NUM_THREADS_PER_CORE do
|
for t = 1, NUM_THREADS_PER_CORE do
|
||||||
local percent = util.conky_numeric(conky_threads[t]) * 0.01
|
local percent = Util.conky_numeric(conky_threads[t]) * 0.01
|
||||||
CompoundDial.set(core.dials, t, percent)
|
CompoundDial.set(core.dials, t, percent)
|
||||||
sum = sum + percent
|
sum = sum + percent
|
||||||
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(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.values, cr, (char_count(process_glob, 'R') - 1)..' | '..
|
Text.set(process.values, cr, (char_count(process_glob, 'R') - 1)..' | '..
|
||||||
|
@ -185,7 +185,7 @@ local update = function(cr)
|
||||||
char_count(process_glob, 'T')..' | '..
|
char_count(process_glob, 'T')..' | '..
|
||||||
char_count(process_glob, 'Z'))
|
char_count(process_glob, 'Z'))
|
||||||
|
|
||||||
local load_percent = util.round(sum / NUM_PHYSICAL_CORES / NUM_THREADS_PER_CORE, 2)
|
local load_percent = Util.round(sum / NUM_PHYSICAL_CORES / NUM_THREADS_PER_CORE, 2)
|
||||||
CriticalText.set(total_load.value, cr, load_percent * 100)
|
CriticalText.set(total_load.value, cr, load_percent * 100)
|
||||||
|
|
||||||
LabelPlot.update(plot, load_percent)
|
LabelPlot.update(plot, load_percent)
|
||||||
|
|
|
@ -2,7 +2,7 @@ local Widget = require 'Widget'
|
||||||
local Text = require 'Text'
|
local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local ScalePlot = require 'ScalePlot'
|
local ScalePlot = require 'ScalePlot'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local __tonumber = tonumber
|
local __tonumber = tonumber
|
||||||
|
@ -18,7 +18,7 @@ local STAT_FILE = '/sys/block/sda/stat'
|
||||||
local RW_REGEX = '%s+%d+%s+%d+%s+(%d+)%s+%d+%s+%d+%s+%d+%s+(%d+)'
|
local RW_REGEX = '%s+%d+%s+%d+%s+(%d+)%s+%d+%s+%d+%s+%d+%s+(%d+)'
|
||||||
|
|
||||||
local read_stat_file = function()
|
local read_stat_file = function()
|
||||||
local bytes_r, bytes_w = __string_match(util.read_file(STAT_FILE), RW_REGEX)
|
local bytes_r, bytes_w = __string_match(Util.read_file(STAT_FILE), RW_REGEX)
|
||||||
return __tonumber(bytes_r) * BLOCK_SIZE_BYTES, __tonumber(bytes_w) * BLOCK_SIZE_BYTES
|
return __tonumber(bytes_r) * BLOCK_SIZE_BYTES, __tonumber(bytes_w) * BLOCK_SIZE_BYTES
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -28,9 +28,9 @@ local update_stat = function(cr, stat, byte_cnt, update_frequency)
|
||||||
|
|
||||||
if delta_bytes > 0 then
|
if delta_bytes > 0 then
|
||||||
local bps = delta_bytes * update_frequency
|
local bps = delta_bytes * update_frequency
|
||||||
local unit = util.get_unit(bps)
|
local unit = Util.get_unit(bps)
|
||||||
stat.rate.append_end = ' '..unit..'/s'
|
stat.rate.append_end = ' '..unit..'/s'
|
||||||
Text.set(stat.rate, cr, util.precision_convert_bytes(bps, 'B', unit, 3))
|
Text.set(stat.rate, cr, Util.precision_convert_bytes(bps, 'B', unit, 3))
|
||||||
ScalePlot.update(stat.plot, cr, bps)
|
ScalePlot.update(stat.plot, cr, bps)
|
||||||
else
|
else
|
||||||
stat.rate.append_end = ' B/s'
|
stat.rate.append_end = ' B/s'
|
||||||
|
@ -40,13 +40,13 @@ local update_stat = function(cr, stat, byte_cnt, update_frequency)
|
||||||
end
|
end
|
||||||
|
|
||||||
local io_label_function = function(bytes)
|
local io_label_function = function(bytes)
|
||||||
local new_unit = util.get_unit(bytes)
|
local new_unit = Util.get_unit(bytes)
|
||||||
|
|
||||||
local converted = util.convert_bytes(bytes, 'B', new_unit)
|
local converted = Util.convert_bytes(bytes, 'B', new_unit)
|
||||||
local precision = 0
|
local precision = 0
|
||||||
if converted < 10 then precision = 1 end
|
if converted < 10 then precision = 1 end
|
||||||
|
|
||||||
return util.round_to_string(converted, precision)..' '..new_unit..'/s'
|
return Util.round_to_string(converted, precision)..' '..new_unit..'/s'
|
||||||
end
|
end
|
||||||
|
|
||||||
local header = Widget.Header{
|
local header = Widget.Header{
|
||||||
|
|
|
@ -2,7 +2,7 @@ local Widget = require 'Widget'
|
||||||
local Text = require 'Text'
|
local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local TextColumn = require 'TextColumn'
|
local TextColumn = require 'TextColumn'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
|
@ -10,7 +10,7 @@ local __string_match = string.match
|
||||||
local _TEXT_SPACING_ = 20
|
local _TEXT_SPACING_ = 20
|
||||||
|
|
||||||
local extract_date = function(cmd)
|
local extract_date = function(cmd)
|
||||||
local yyyy, mm_dd = __string_match(util.execute_cmd(cmd), '%[(%d-)%-(%d-%-%d-)%s')
|
local yyyy, mm_dd = __string_match(Util.execute_cmd(cmd), '%[(%d-)%-(%d-%-%d-)%s')
|
||||||
return mm_dd..'-'..yyyy
|
return mm_dd..'-'..yyyy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ local info = Widget.TextColumn{
|
||||||
spacing = _TEXT_SPACING_,
|
spacing = _TEXT_SPACING_,
|
||||||
x_align = 'right',
|
x_align = 'right',
|
||||||
text_color = Patterns.BLUE,
|
text_color = Patterns.BLUE,
|
||||||
util.conky('$kernel'),
|
Util.conky('$kernel'),
|
||||||
'<row2>',
|
'<row2>',
|
||||||
'<row3>',
|
'<row3>',
|
||||||
'<row4>'
|
'<row4>'
|
||||||
|
@ -47,7 +47,7 @@ Patterns = nil
|
||||||
_TEXT_SPACING_ = nil
|
_TEXT_SPACING_ = nil
|
||||||
|
|
||||||
local draw = function(cr, current_interface, log_is_changed)
|
local draw = function(cr, current_interface, log_is_changed)
|
||||||
TextColumn.set(info, cr, 2, util.conky('$uptime'))
|
TextColumn.set(info, cr, 2, Util.conky('$uptime'))
|
||||||
|
|
||||||
if log_is_changed then
|
if log_is_changed then
|
||||||
TextColumn.set(info, cr, 3, extract_date("sed -n "..
|
TextColumn.set(info, cr, 3, extract_date("sed -n "..
|
||||||
|
|
|
@ -3,8 +3,8 @@ local Text = require 'Text'
|
||||||
local Line = require 'Line'
|
local Line = require 'Line'
|
||||||
local TextColumn = require 'TextColumn'
|
local TextColumn = require 'TextColumn'
|
||||||
local ScaledImage = require 'ScaledImage'
|
local ScaledImage = require 'ScaledImage'
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local json = require 'json'
|
local Json = require 'Json'
|
||||||
local Patterns = require 'Patterns'
|
local Patterns = require 'Patterns'
|
||||||
|
|
||||||
local __string_match = string.match
|
local __string_match = string.match
|
||||||
|
@ -307,8 +307,8 @@ local populate_center = function(center_section, cr, desc, icon_path, temp,
|
||||||
end
|
end
|
||||||
|
|
||||||
local update_interface = function(cr)
|
local update_interface = function(cr)
|
||||||
local file = util.read_file(WEATHER_JSON_PATH)
|
local file = Util.read_file(WEATHER_JSON_PATH)
|
||||||
local data = (file ~= '') and json.decode(file)
|
local data = (file ~= '') and Json.decode(file)
|
||||||
|
|
||||||
if data then
|
if data then
|
||||||
data = data.response.responses
|
data = data.response.responses
|
||||||
|
@ -330,7 +330,7 @@ local update_interface = function(cr)
|
||||||
left.hours[i],
|
left.hours[i],
|
||||||
cr,
|
cr,
|
||||||
hour_data.weatherPrimary,
|
hour_data.weatherPrimary,
|
||||||
hour_data.timestamp and util.convert_unix_time(hour_data.timestamp, TIME_FORMAT),
|
hour_data.timestamp and Util.convert_unix_time(hour_data.timestamp, TIME_FORMAT),
|
||||||
hour_data.icon and ICON_DIR_PATH..hour_data.icon,
|
hour_data.icon and ICON_DIR_PATH..hour_data.icon,
|
||||||
hour_data.avgTempF and hour_data.avgTempF..'°F',
|
hour_data.avgTempF and hour_data.avgTempF..'°F',
|
||||||
hour_data.feelslikeF and 'Feels like '..hour_data.feelslikeF..'°F',
|
hour_data.feelslikeF and 'Feels like '..hour_data.feelslikeF..'°F',
|
||||||
|
@ -347,7 +347,7 @@ local update_interface = function(cr)
|
||||||
local place
|
local place
|
||||||
if current_data.place then
|
if current_data.place then
|
||||||
place = current_data.place.name
|
place = current_data.place.name
|
||||||
if place then place = util.capitalize_each_word(__string_match(place, '([%w%s]+)/?')) end
|
if place then place = Util.capitalize_each_word(__string_match(place, '([%w%s]+)/?')) end
|
||||||
|
|
||||||
local state = current_data.place.state
|
local state = current_data.place.state
|
||||||
if state == '' then state = nil end
|
if state == '' then state = nil end
|
||||||
|
@ -366,7 +366,7 @@ local update_interface = function(cr)
|
||||||
ob.weather,
|
ob.weather,
|
||||||
ob.icon and ICON_DIR_PATH..ob.icon,
|
ob.icon and ICON_DIR_PATH..ob.icon,
|
||||||
ob.tempF and ob.tempF..'°F',
|
ob.tempF and ob.tempF..'°F',
|
||||||
ob.timestamp and util.convert_unix_time(ob.timestamp, TIME_FORMAT),
|
ob.timestamp and Util.convert_unix_time(ob.timestamp, TIME_FORMAT),
|
||||||
place,
|
place,
|
||||||
ob.feelslikeF and ob.feelslikeF..'°F',
|
ob.feelslikeF and ob.feelslikeF..'°F',
|
||||||
ob.dewpointF and ob.dewpointF..'°F',
|
ob.dewpointF and ob.dewpointF..'°F',
|
||||||
|
@ -379,8 +379,8 @@ local update_interface = function(cr)
|
||||||
ob.windGustMPH and ob.windGustMPH..' mph',
|
ob.windGustMPH and ob.windGustMPH..' mph',
|
||||||
ob.windDirDEG and ob.windDirDEG..' deg',
|
ob.windDirDEG and ob.windDirDEG..' deg',
|
||||||
ob.pressureMB and ob.pressureMB..' mbar',
|
ob.pressureMB and ob.pressureMB..' mbar',
|
||||||
ob.sunrise and util.convert_unix_time(ob.sunrise, TIME_FORMAT),
|
ob.sunrise and Util.convert_unix_time(ob.sunrise, TIME_FORMAT),
|
||||||
ob.sunset and util.convert_unix_time(ob.sunset, TIME_FORMAT),
|
ob.sunset and Util.convert_unix_time(ob.sunset, TIME_FORMAT),
|
||||||
ob.light and ob.light..' %'
|
ob.light and ob.light..' %'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ local update_interface = function(cr)
|
||||||
right.days[i],
|
right.days[i],
|
||||||
cr,
|
cr,
|
||||||
day_data.weatherPrimary,
|
day_data.weatherPrimary,
|
||||||
day_data.timestamp and __string_sub(util.convert_unix_time(
|
day_data.timestamp and __string_sub(Util.convert_unix_time(
|
||||||
day_data.timestamp, DATE_FORMAT), 1, 3),
|
day_data.timestamp, DATE_FORMAT), 1, 3),
|
||||||
day_data.icon and ICON_DIR_PATH..day_data.icon,
|
day_data.icon and ICON_DIR_PATH..day_data.icon,
|
||||||
day_data.maxTempF and day_data.maxTempF..'°F',
|
day_data.maxTempF and day_data.maxTempF..'°F',
|
||||||
|
@ -438,11 +438,11 @@ local update_cycle = WEATHER_UPDATE_INTERVAL
|
||||||
local draw = function(cr, interface, interface_is_changed)
|
local draw = function(cr, interface, interface_is_changed)
|
||||||
if update_cycle == 0 then __os_execute('get_weather.sh') end
|
if update_cycle == 0 then __os_execute('get_weather.sh') end
|
||||||
|
|
||||||
local json_is_recently_updated = (util.read_file(RECENTLY_UPDATED_PATH, nil, '*l') == 'true')
|
local json_is_recently_updated = (Util.read_file(RECENTLY_UPDATED_PATH, nil, '*l') == 'true')
|
||||||
|
|
||||||
if json_is_recently_updated then
|
if json_is_recently_updated then
|
||||||
update_cycle = WEATHER_UPDATE_INTERVAL
|
update_cycle = WEATHER_UPDATE_INTERVAL
|
||||||
util.write_file(RECENTLY_UPDATED_PATH, 'false')
|
Util.write_file(RECENTLY_UPDATED_PATH, 'false')
|
||||||
end
|
end
|
||||||
|
|
||||||
if json_is_recently_updated or interface_is_changed then update_interface(cr) end
|
if json_is_recently_updated or interface_is_changed then update_interface(cr) end
|
||||||
|
|
10
main.lua
10
main.lua
|
@ -100,7 +100,7 @@ conky_set_update_interval(_G_INIT_DATA_.UPDATE_INTERVAL)
|
||||||
require 'imlib2'
|
require 'imlib2'
|
||||||
require 'cairo'
|
require 'cairo'
|
||||||
|
|
||||||
local util = require 'util'
|
local Util = require 'Util'
|
||||||
local Panel = require 'Panel'
|
local Panel = require 'Panel'
|
||||||
local System = require 'System'
|
local System = require 'System'
|
||||||
local Network = require 'Network'
|
local Network = require 'Network'
|
||||||
|
@ -136,13 +136,13 @@ local __collectgarbage = collectgarbage
|
||||||
local __os_execute = os.execute
|
local __os_execute = os.execute
|
||||||
|
|
||||||
local using_ac = function()
|
local using_ac = function()
|
||||||
return util.conky('${acpiacadapter AC}') == 'on-line'
|
return Util.conky('${acpiacadapter AC}') == 'on-line'
|
||||||
end
|
end
|
||||||
|
|
||||||
local current_last_log_entry = util.execute_cmd('tail -1 /var/log/pacman.log')
|
local current_last_log_entry = Util.execute_cmd('tail -1 /var/log/pacman.log')
|
||||||
|
|
||||||
local check_if_log_changed = function()
|
local check_if_log_changed = function()
|
||||||
local new_last_log_entry = util.execute_cmd('tail -1 /var/log/pacman.log')
|
local new_last_log_entry = Util.execute_cmd('tail -1 /var/log/pacman.log')
|
||||||
if new_last_log_entry == current_last_log_entry then return 1 end
|
if new_last_log_entry == current_last_log_entry then return 1 end
|
||||||
current_last_log_entry = new_last_log_entry
|
current_last_log_entry = new_last_log_entry
|
||||||
return 0
|
return 0
|
||||||
|
@ -174,7 +174,7 @@ function conky_main()
|
||||||
|
|
||||||
local interface_is_changed = false
|
local interface_is_changed = false
|
||||||
|
|
||||||
local next_interface = util.read_file('/tmp/conky_interface', nil, '*n')
|
local next_interface = Util.read_file('/tmp/conky_interface', nil, '*n')
|
||||||
|
|
||||||
if next_interface == '' then
|
if next_interface == '' then
|
||||||
__os_execute('set_conky_interface.sh 0')
|
__os_execute('set_conky_interface.sh 0')
|
||||||
|
|
Loading…
Reference in New Issue