update for clevo n855hj

This commit is contained in:
petrucci4prez 2017-07-15 20:08:39 -04:00
parent 9faa50d72c
commit 7fa168a925
14 changed files with 869 additions and 301 deletions

View File

@ -13,8 +13,8 @@ conky.config = {
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
double_buffer = true,
minimum_width = 1377,
minimum_height = 778,
minimum_width = 1920,
minimum_height = 1080,
draw_shades = false,
draw_outline = false,

View File

@ -1,26 +1,23 @@
local Widget = require 'Widget'
local FillRect = require 'FillRect'
local PAD_X = 20
local PAD_Y = 10
local left = Widget.Panel{
x = CONSTRUCTION_GLOBAL.LEFT_X - PAD_X,
y = CONSTRUCTION_GLOBAL.TOP_Y - PAD_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH + PAD_X * 2,
height = CONSTRUCTION_GLOBAL.SIDE_HEIGHT + PAD_Y * 2,
x = CONSTRUCTION_GLOBAL.LEFT_X - CONSTRUCTION_GLOBAL.PANEL_MARGIN_X,
y = CONSTRUCTION_GLOBAL.TOP_Y - CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH + CONSTRUCTION_GLOBAL.PANEL_MARGIN_X * 2,
height = CONSTRUCTION_GLOBAL.SIDE_HEIGHT + CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y * 2,
}
local center = Widget.Panel{
x = CONSTRUCTION_GLOBAL.CENTER_X - PAD_X,
y = CONSTRUCTION_GLOBAL.TOP_Y - PAD_Y,
width = CONSTRUCTION_GLOBAL.CENTER_WIDTH + PAD_X * 2,
height = CONSTRUCTION_GLOBAL.CENTER_HEIGHT + PAD_Y * 2,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X - CONSTRUCTION_GLOBAL.PANEL_MARGIN_X,
y = CONSTRUCTION_GLOBAL.TOP_Y - CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y,
width = CONSTRUCTION_GLOBAL.CENTER_WIDTH + CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y * 2 + CONSTRUCTION_GLOBAL.CENTER_PAD,
height = CONSTRUCTION_GLOBAL.CENTER_HEIGHT + CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y * 2,
}
local right = Widget.Panel{
x = CONSTRUCTION_GLOBAL.RIGHT_X - PAD_X,
y = CONSTRUCTION_GLOBAL.TOP_Y - PAD_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH + PAD_X * 2,
height = CONSTRUCTION_GLOBAL.SIDE_HEIGHT + PAD_Y * 2,
x = CONSTRUCTION_GLOBAL.RIGHT_X - CONSTRUCTION_GLOBAL.PANEL_MARGIN_X,
y = CONSTRUCTION_GLOBAL.TOP_Y - CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH + CONSTRUCTION_GLOBAL.PANEL_MARGIN_X * 2,
height = CONSTRUCTION_GLOBAL.SIDE_HEIGHT + CONSTRUCTION_GLOBAL.PANEL_MARGIN_Y * 2,
}
Widget = nil

View File

@ -21,17 +21,26 @@ local UPDATE_FREQUENCY = 1 --Hz
CONSTRUCTION_GLOBAL = {
UPDATE_INTERVAL = 1 / UPDATE_FREQUENCY,
LEFT_X = 30,
CENTER_X = 376,
RIGHT_X = 1045,
LEFT_X = 32,
SECTION_WIDTH = 436,
CENTER_PAD = 20,
PANEL_HORZ_SPACING = 10,
PANEL_MARGIN_X = 20,
PANEL_MARGIN_Y = 10,
TOP_Y = 21,
SIDE_WIDTH = 300,
SIDE_HEIGHT = 709,
CENTER_WIDTH = 623,
CENTER_HEIGHT = 154,
SIDE_HEIGHT = 1020,
CENTER_HEIGHT = 220,
ABS_PATH = ABS_PATH
}
CONSTRUCTION_GLOBAL.CENTER_LEFT_X = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH + CONSTRUCTION_GLOBAL.PANEL_MARGIN_X * 2 + CONSTRUCTION_GLOBAL.PANEL_HORZ_SPACING
CONSTRUCTION_GLOBAL.CENTER_RIGHT_X = CONSTRUCTION_GLOBAL.CENTER_LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH + CONSTRUCTION_GLOBAL.CENTER_PAD
CONSTRUCTION_GLOBAL.CENTER_WIDTH = CONSTRUCTION_GLOBAL.SECTION_WIDTH * 2 + CONSTRUCTION_GLOBAL.CENTER_PAD
CONSTRUCTION_GLOBAL.RIGHT_X = CONSTRUCTION_GLOBAL.CENTER_LEFT_X + CONSTRUCTION_GLOBAL.CENTER_WIDTH + CONSTRUCTION_GLOBAL.PANEL_MARGIN_X * 2 + CONSTRUCTION_GLOBAL.PANEL_HORZ_SPACING
ABS_PATH = nil
conky_set_update_interval(CONSTRUCTION_GLOBAL.UPDATE_INTERVAL)
@ -46,7 +55,9 @@ local Network = require 'Network'
local Processor = require 'Processor'
local FileSystem = require 'FileSystem'
local Pacman = require 'Pacman'
local Power = require 'Power'
local ReadWrite = require 'ReadWrite'
local Graphics = require 'Graphics'
local Memory = require 'Memory'
local Weather = require 'Weather'
@ -106,7 +117,7 @@ function conky_main()
local cw = conky_window
if not cw then return end
--~ print(cw.width, cw.height) ###USE THIS TO GET WIDTH AND HEIGHT OF WINDOW
local cs = _CAIRO_XLIB_SURFACE_CREATE(cw.display, cw.drawable, cw.visual, 1377, 778)
local cs = _CAIRO_XLIB_SURFACE_CREATE(cw.display, cw.drawable, cw.visual, 1920, 1080)
local cr = _CAIRO_CREATE(cs)
updates = updates + 1
@ -114,7 +125,8 @@ function conky_main()
local t1 = updates % (UPDATE_FREQUENCY * 10)
local t2
if using_ac() then
local ac = using_ac()
if ac then
t2 = updates % (UPDATE_FREQUENCY * 60)
else
t2 = updates % (UPDATE_FREQUENCY * 300)
@ -128,16 +140,16 @@ function conky_main()
--interface 0
System(cr, current_interface, log_changed)
Network(cr, current_interface, UPDATE_FREQUENCY)
Graphics(cr, current_interface)
Processor(cr, current_interface)
FileSystem(cr, current_interface, t1)
Pacman(cr, current_interface, log_changed)
ReadWrite(cr, current_interface, UPDATE_FREQUENCY)
Memory(cr, current_interface)
--interface 1
--~ USB(cr, current_interface)
--~ Remote(cr, current_interface, t1)
ReadWrite(cr, current_interface, UPDATE_FREQUENCY)
Network(cr, current_interface, UPDATE_FREQUENCY)
Pacman(cr, current_interface, log_changed)
FileSystem(cr, current_interface, t1)
Power(cr, current_interface, UPDATE_FREQUENCY, ac)
Memory(cr, current_interface)
--interface 1
Weather(cr, current_interface, interface_changed)

View File

@ -16,21 +16,22 @@ local FS_NUM = #FS_PATHS
local FS_REGEX = '^([%d%p]-)(%a+)'
--construction params
local MODULE_Y = 165
local SPACING = 20
local TEXT_WIDTH = 200
local BAR_PAD = 20
--~ local TEXT_WIDTH = 220
local BAR_PAD = 100
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.CENTER_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.CENTER_WIDTH,
header = "FILE SYSTEMS"
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = 'FILE SYSTEMS'
}
local HEADER_BOTTOM_Y = header.bottom_y
local labels = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.CENTER_X,
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = HEADER_BOTTOM_Y,
spacing = SPACING,
'root',
@ -41,33 +42,35 @@ local labels = Widget.TextColumn{
'lopt'
}
local totals = {}
--~ local totals = {}
for i = 1, FS_NUM do
totals[i] = Widget.CriticalText{
x = CONSTRUCTION_GLOBAL.CENTER_X + TEXT_WIDTH,
y = HEADER_BOTTOM_Y + (i - 1) * SPACING,
x_align = 'right',
text_color = schema.blue,
}
end
--~ for i = 1, FS_NUM do
--~ totals[i] = Widget.CriticalText{
--~ x = CONSTRUCTION_GLOBAL.RIGHT_X + TEXT_WIDTH,
--~ y = HEADER_BOTTOM_Y + (i - 1) * SPACING,
--~ x_align = 'right',
--~ text_color = schema.blue,
--~ }
--~ end
local units = {}
local conky_used = {}
--~ local units = {}
--~ local conky_used = {}
local conky_used_perc = {}
for i, v in _PAIRS(FS_PATHS) do
local size, unit = _STRING_MATCH(util.conky('${fs_size '..v..'}'), FS_REGEX)
totals[i].append_end = ' / '..size..' ('..unit..')'
units[i] = unit
conky_used[i] = '${fs_used '..v..'}'
--~ local size, unit = _STRING_MATCH(util.conky('${fs_size '..v..'}'), FS_REGEX)
--~ totals[i].append_end = ' / '..size..' ('..unit..')'
--~ units[i] = unit
--~ conky_used[i] = '${fs_used '..v..'}'
conky_used_perc[i] = '${fs_used_perc '..v..'}'
end
local bars = Widget.CompoundBar{
x = CONSTRUCTION_GLOBAL.CENTER_X + TEXT_WIDTH + BAR_PAD,
--~ x = CONSTRUCTION_GLOBAL.RIGHT_X + TEXT_WIDTH + BAR_PAD,
x = CONSTRUCTION_GLOBAL.RIGHT_X + BAR_PAD,
y = HEADER_BOTTOM_Y,
length = CONSTRUCTION_GLOBAL.CENTER_WIDTH - (TEXT_WIDTH + BAR_PAD),
--~ length = CONSTRUCTION_GLOBAL.SECTION_WIDTH - (TEXT_WIDTH + BAR_PAD),
length = CONSTRUCTION_GLOBAL.SECTION_WIDTH - BAR_PAD,
spacing = SPACING,
num_bars = FS_NUM,
critical_limit = '>0.8'
@ -85,11 +88,11 @@ HEADER_BOTTOM_Y = nil
local __update = function(cr)
for i = 1, FS_NUM do
local value, unit = _STRING_MATCH(util.conky(conky_used[i]), FS_REGEX)
--~ local value, unit = _STRING_MATCH(util.conky(conky_used[i]), FS_REGEX)
local percent = util.conky_numeric(conky_used_perc[i])
local force = 1
if percent > 80 then force = 0 end
CriticalText.set(totals[i], cr, util.precision_convert_bytes(value, unit, units[i], 3), force)
--~ local force = 1
--~ if percent > 80 then force = 0 end
--~ CriticalText.set(totals[i], cr, util.precision_convert_bytes(value, unit, units[i], 3), force)
CompoundBar.set(bars, i, percent * 0.01)
end
end
@ -105,9 +108,9 @@ local draw = function(cr, current_interface, trigger)
Text.draw(header.text, cr)
Line.draw(header.underline, cr)
TextColumn.draw(labels, cr)
for i = 1, FS_NUM do
CriticalText.draw(totals[i], cr)
end
--~ for i = 1, FS_NUM do
--~ CriticalText.draw(totals[i], cr)
--~ end
CompoundBar.draw(bars, cr)
end
end

328
module/Graphics.lua Normal file
View File

@ -0,0 +1,328 @@
local Widget = require 'Widget'
local CriticalText = require 'CriticalText'
local Text = require 'Text'
local TextColumn = require 'TextColumn'
local Line = require 'Line'
local LabelPlot = require 'LabelPlot'
local util = require 'util'
local schema = require 'default_patterns'
local _TONUMBER = tonumber
--construction params
local MODULE_Y = 145
local SEPARATOR_SPACING = 20
local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = 'NVIDIA GRAPHICS'
}
local RIGHT_X = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH
local status = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = header.bottom_y,
text = 'Status'
},
value = Widget.Text{
x = RIGHT_X,
y = header.bottom_y,
x_align = 'right',
text_color = schema.blue,
text = '<status>'
}
}
local SEP_Y_1 = header.bottom_y + SEPARATOR_SPACING
local separator1 = Widget.Line{
p1 = {x = CONSTRUCTION_GLOBAL.LEFT_X, y = SEP_Y_1},
p2 = {x = RIGHT_X, y = SEP_Y_1}
}
local INTERNAL_TEMP_Y = SEP_Y_1 + SEPARATOR_SPACING
local internal_temp = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = INTERNAL_TEMP_Y,
text = 'Internal Temperature'
},
value = Widget.CriticalText{
x = RIGHT_X,
y = INTERNAL_TEMP_Y,
x_align = 'right',
text_color = schema.blue,
text = '<gpu_temp>'
}
}
local PCI_UTIL_Y = INTERNAL_TEMP_Y + TEXT_SPACING
local pci_util = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = PCI_UTIL_Y,
text = 'PCI Utilization'
},
value = Widget.Text{
x = RIGHT_X,
y = PCI_UTIL_Y,
x_align = 'right',
text_color = schema.blue,
text = '<pci_util>'
}
}
local SEP_Y_2 = PCI_UTIL_Y + SEPARATOR_SPACING
local separator2 = Widget.Line{
p1 = {x = CONSTRUCTION_GLOBAL.LEFT_X, y = SEP_Y_2},
p2 = {x = RIGHT_X, y = SEP_Y_2}
}
local CLOCK_SPEED_Y = SEP_Y_2 + SEPARATOR_SPACING
local clock_speed = {
labels = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = CLOCK_SPEED_Y,
spacing = TEXT_SPACING,
'GPU Clock Speed',
'Memory Clock Speed'
},
values = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = CLOCK_SPEED_Y,
spacing = TEXT_SPACING,
x_align = 'right',
text_color = schema.blue,
num_rows = 2
}
}
local SEP_Y_3 = CLOCK_SPEED_Y + TEXT_SPACING * 2
local separator3 = Widget.Line{
p1 = {x = CONSTRUCTION_GLOBAL.LEFT_X, y = SEP_Y_3},
p2 = {x = RIGHT_X, y = SEP_Y_3}
}
local GPU_UTIL_Y = SEP_Y_3 + SEPARATOR_SPACING
local GPU_UTIL_PLOT_Y = GPU_UTIL_Y + PLOT_SEC_BREAK
local gpu_util = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = GPU_UTIL_Y,
text = 'GPU Utilization'
},
value = Widget.Text{
x = RIGHT_X,
y = GPU_UTIL_Y,
x_align = 'right',
text_color = schema.blue,
text = '<gpu_util>'
},
plot = Widget.LabelPlot{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = GPU_UTIL_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT
}
}
local MEM_UTIL_Y = GPU_UTIL_PLOT_Y + PLOT_HEIGHT + PLOT_SEC_BREAK
local MEM_UTIL_PLOT_Y = MEM_UTIL_Y + PLOT_SEC_BREAK
local mem_util = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = MEM_UTIL_Y,
text = 'Memory Utilization'
},
value = Widget.Text{
x = RIGHT_X,
y = MEM_UTIL_Y,
x_align = 'right',
text_color = schema.blue,
text = '<mem_util>'
},
plot = Widget.LabelPlot{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = MEM_UTIL_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT
}
}
local VID_UTIL_Y = MEM_UTIL_PLOT_Y + PLOT_HEIGHT + PLOT_SEC_BREAK
local VID_UTIL_PLOT_Y = VID_UTIL_Y + PLOT_SEC_BREAK
local vid_util = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = VID_UTIL_Y,
text = 'Video Utilization'
},
value = Widget.Text{
x = RIGHT_X,
y = VID_UTIL_Y,
x_align = 'right',
text_color = schema.blue,
text = '<vid_util>'
},
plot = Widget.LabelPlot{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = VID_UTIL_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT
}
}
--[[
vars to process the nv settings glob
glob will be of the form:
<used_mem>
<total_mem>
<temp>
<gpu_freq>,<mem_freq>
graphics=<gpu_util>, memory=<mem_util>, video=<vid_util>, PCIe=<pci_util>
--]]
local NV_QUERY = 'optirun nvidia-settings -c :8 -t'..
' -q UsedDedicatedGPUMemory'..
' -q TotalDedicatedGPUMemory'..
' -q ThermalSensorReading'..
' -q [gpu:0]/GPUCurrentClockFreqs'..
' -q [gpu:0]/GPUUtilization'
local NV_REGEX = '(%d+)\n'..
'(%d+)\n'..
'(%d+)\n'..
'(%d+),(%d+)\n'..
'graphics=(%d+), memory=%d+, video=(%d+), PCIe=(%d+)\n'
local __nvidia_off = function(cr)
CriticalText.set(internal_temp.value, cr, 'N/A', 1)
Text.set(pci_util.value, cr, 'N/A')
TextColumn.set(clock_speed.values, cr, 1, 'N/A')
TextColumn.set(clock_speed.values, cr, 2, 'N/A')
Text.set(gpu_util.value, cr, 'N/A')
Text.set(mem_util.value, cr, 'N/A')
Text.set(vid_util.value, cr, 'N/A')
LabelPlot.update(gpu_util.plot, 0)
LabelPlot.update(mem_util.plot, 0)
LabelPlot.update(vid_util.plot, 0)
end
local __update = function(cr)
if util.read_file('/proc/acpi/bbswitch', '.+%s+(%u+)') == 'ON' then
if string.find(util.execute_cmd('ps -A -o comm'), 'optirun') == nil then
Text.set(status.value, cr, 'Mixed')
__nvidia_off(cr)
else
Text.set(status.value, cr, 'On')
local nvidia_settings_glob = util.execute_cmd(NV_QUERY)
local used_memory, total_memory, temp_reading, gpu_frequency,
memory_frequency, gpu_utilization, vid_utilization,
pci_utilization = string.match(nvidia_settings_glob, NV_REGEX)
local force = 1
if _TONUMBER(temp_reading) > 80 then force = 0 end
CriticalText.set(internal_temp.value, cr, temp_reading..'°C', force)
Text.set(pci_util.value, cr, pci_utilization..'%')
TextColumn.set(clock_speed.values, cr, 1, gpu_frequency..' Mhz')
TextColumn.set(clock_speed.values, cr, 2, memory_frequency..' Mhz')
local percent_used_memory = used_memory / total_memory
Text.set(gpu_util.value, cr, gpu_utilization..'%')
Text.set(mem_util.value, cr, util.round(percent_used_memory * 100)..'%')
Text.set(vid_util.value, cr, vid_utilization..'%')
LabelPlot.update(gpu_util.plot, gpu_utilization * 0.01)
LabelPlot.update(mem_util.plot, percent_used_memory)
LabelPlot.update(vid_util.plot, vid_utilization * 0.01)
end
else
Text.set(status.value, cr, 'Off')
__nvidia_off(cr)
end
end
Widget = nil
schema = nil
MODULE_Y = nil
SEPARATOR_SPACING = nil
TEXT_SPACING = nil
PLOT_SECTION_BREAK = nil
PLOT_HEIGHT = nil
RIGHT_X = nil
SEP_Y_1 = nil
SEP_Y_2 = nil
SEP_Y_3 = nil
INTERNAL_TEMP_Y = nil
PCI_UTIL_Y = nil
CLOCK_SPEED_Y = nil
GPU_UTIL_Y = nil
GPU_UTIL_PLOT_Y = nil
MEM_UTIL_Y = nil
MEM_UTIL_PLOT_Y = nil
VID_UTIL_Y = nil
VID_UTIL_PLOT_Y = nil
local draw = function(cr, current_interface)
__update(cr)
if current_interface == 0 then
Text.draw(header.text, cr)
Line.draw(header.underline, cr)
Text.draw(status.label, cr)
Text.draw(status.value, cr)
Line.draw(separator1, cr)
Text.draw(internal_temp.label, cr)
Text.draw(internal_temp.value, cr)
Text.draw(pci_util.label, cr)
Text.draw(pci_util.value, cr)
Line.draw(separator2, cr)
TextColumn.draw(clock_speed.labels, cr)
TextColumn.draw(clock_speed.values, cr)
Line.draw(separator3, cr)
Text.draw(gpu_util.label, cr)
Text.draw(gpu_util.value, cr)
LabelPlot.draw(gpu_util.plot, cr)
Text.draw(mem_util.label, cr)
Text.draw(mem_util.value, cr)
LabelPlot.draw(mem_util.plot, cr)
Text.draw(vid_util.label, cr)
Text.draw(vid_util.value, cr)
LabelPlot.draw(vid_util.plot, cr)
end
end
return draw

View File

@ -15,7 +15,7 @@ local _MATH_RAD = math.rad
local _CAIRO_PATH_DESTROY = cairo_path_destroy
local MODULE_Y = 397
local MODULE_Y = 712
local MEM_TOTAL = tonumber(util.read_file('/proc/meminfo', 'MemTotal:%s+(%d+)')) --in kB
@ -44,7 +44,7 @@ local TABLE_HEIGHT = 114
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "MEMORY"
}
@ -86,7 +86,7 @@ local inner_ring = Widget.Arc{
local LINE_1_Y = HEADER_BOTTOM_Y + TEXT_Y_OFFSET
local TEXT_LEFT_X = CONSTRUCTION_GLOBAL.RIGHT_X + DIAL_RADIUS * 2 + TEXT_LEFT_X_OFFSET
local RIGHT_X = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SIDE_WIDTH
local RIGHT_X = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH
local swap= {
label = Widget.Text{
@ -129,7 +129,7 @@ local PLOT_Y = PLOT_SECTION_BREAK + HEADER_BOTTOM_Y + DIAL_RADIUS * 2
local plot = Widget.LabelPlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT
}
@ -138,7 +138,7 @@ local TABLE_Y = PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK
local tbl = Widget.Table{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = TABLE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = TABLE_HEIGHT,
'Name',
'PID',

View File

@ -8,8 +8,6 @@ local schema = require 'default_patterns'
local _STRING_GMATCH = string.gmatch
local _IO_POPEN = io.popen
local MODULE_Y = 145
--construction params
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
@ -29,18 +27,18 @@ local __network_label_function = function(bytes)
end
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "NETWORK"
}
local RIGHT_X = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SIDE_WIDTH
local RIGHT_X = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH
local DOWNLOAD_PLOT_Y = header.bottom_y + PLOT_SEC_BREAK
local dnload = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X,
y = header.bottom_y,
text = 'Download',
},
@ -51,9 +49,9 @@ local dnload = {
text_color = schema.blue
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.LEFT_X,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X,
y = DOWNLOAD_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __network_label_function
}
@ -64,7 +62,7 @@ local UPLOAD_PLOT_Y = UPLOAD_Y + PLOT_SEC_BREAK
local upload = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X,
y = UPLOAD_Y,
text = 'Upload',
},
@ -75,9 +73,9 @@ local upload = {
text_color = schema.blue
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.LEFT_X,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X,
y = UPLOAD_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __network_label_function
}
@ -149,7 +147,6 @@ end
Widget = nil
schema = nil
MODULE_Y = nil
PLOT_SEC_BREAK = nil
PLOT_HEIGHT = nil
RIGHT_X = nil

View File

@ -12,7 +12,7 @@ local TEXT_SPACING = 20
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "PACMAN"
}
@ -27,7 +27,7 @@ local labels = Widget.TextColumn{
'Local'
}
local info = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = header.bottom_y,
spacing = TEXT_SPACING,
x_align = 'right',

210
module/Power.lua Normal file
View File

@ -0,0 +1,210 @@
local Widget = require 'Widget'
local Text = require 'Text'
local TextColumn = require 'TextColumn'
local Line = require 'Line'
local ScalePlot = require 'ScalePlot'
local util = require 'util'
local schema = require 'default_patterns'
local _STRING_MATCH = string.match
local _MATH_RAD = math.rad
--construction params
local MODULE_Y = 328
local SEPARATOR_SPACING = 20
local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
local __power_label_function = function(watts)
return watts..' W'
end
local __calculate_power = function(cr, prev_cnt, cnt, update_frequency)
return cnt > prev_cnt and (cnt - prev_cnt) * update_frequency * 0.000001 or 0
end
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = 'POWER'
}
local RIGHT_X = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH
local pp01 = {
labels = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = header.bottom_y,
spacing = TEXT_SPACING,
'Core',
'iGPU'
},
values = Widget.TextColumn{
x = RIGHT_X,
y = header.bottom_y,
spacing = TEXT_SPACING,
x_align = 'right',
text_color = schema.blue,
append_end = ' W',
num_rows = 2
}
}
local SEP_Y = header.bottom_y + TEXT_SPACING + SEPARATOR_SPACING
local separator = Widget.Line{
p1 = {x = CONSTRUCTION_GLOBAL.RIGHT_X, y = SEP_Y},
p2 = {x = RIGHT_X, y = SEP_Y}
}
local PKG0_Y = SEP_Y + SEPARATOR_SPACING
local pkg0 = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = PKG0_Y,
text = 'PKG 0'
},
value = Widget.Text{
x = RIGHT_X,
y = PKG0_Y,
x_align = 'right',
text_color = schema.blue,
text = '<pkg0>',
append_end = ' W'
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = PKG0_Y + PLOT_SEC_BREAK,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __power_label_function,
}
}
local DRAM_Y = PKG0_Y + PLOT_SEC_BREAK * 2 + PLOT_HEIGHT
local dram = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = DRAM_Y,
text = 'DRAM'
},
value = Widget.Text{
x = RIGHT_X,
y = DRAM_Y,
x_align = 'right',
text_color = schema.blue,
text = '<dram>',
append_end = ' W'
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = DRAM_Y + PLOT_SEC_BREAK,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __power_label_function,
}
}
local BATTERY_DRAW_Y = DRAM_Y + PLOT_SEC_BREAK * 2 + PLOT_HEIGHT
local battery_draw = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = BATTERY_DRAW_Y,
spacing = TEXT_SPACING,
text = 'Battery Draw'
},
value = Widget.CriticalText{
x = RIGHT_X,
y = BATTERY_DRAW_Y,
x_align = 'right',
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = BATTERY_DRAW_Y + PLOT_SEC_BREAK,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __power_label_function,
}
}
local PKG0_PATH = '/sys/class/powercap/intel-rapl:0/energy_uj'
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 DRAM_PATH = '/sys/class/powercap/intel-rapl:0:2/energy_uj'
local PKG0_PREV_CNT = util.read_file(PKG0_PATH, nil, '*n')
local CORE_PREV_CNT = util.read_file(CORE_PATH, nil, '*n')
local IGPU_PREV_CNT = util.read_file(IGPU_PATH, nil, '*n')
local DRAM_PREV_CNT = util.read_file(DRAM_PATH, nil, '*n')
local __update = function(cr, update_frequency, ac_active)
local pkg0_cnt = util.read_file(PKG0_PATH, nil, '*n')
local core_cnt = util.read_file(CORE_PATH, nil, '*n')
local igpu_cnt = util.read_file(IGPU_PATH, nil, '*n')
local dram_cnt = util.read_file(DRAM_PATH, nil, '*n')
TextColumn.set(pp01.values, cr, 1, util.precision_round_to_string(
__calculate_power(cr, CORE_PREV_CNT, core_cnt, update_frequency), 3))
TextColumn.set(pp01.values, cr, 2, util.precision_round_to_string(
__calculate_power(cr, IGPU_PREV_CNT, igpu_cnt, update_frequency), 3))
local pkg0_power = __calculate_power(cr, PKG0_PREV_CNT, pkg0_cnt, update_frequency)
local dram_power = __calculate_power(cr, DRAM_PREV_CNT, dram_cnt, update_frequency)
Text.set(pkg0.value, cr, util.precision_round_to_string(pkg0_power, 3))
ScalePlot.update(pkg0.plot, cr, pkg0_power)
Text.set(dram.value, cr, util.precision_round_to_string(dram_power, 3))
ScalePlot.update(dram.plot, cr, dram_power)
PKG0_PREV_CNT = pkg0_cnt
CORE_PREV_CNT = core_cnt
IGPU_PREV_CNT = igpu_cnt
DRAM_PREV_CNT = dram_cnt
if ac_active then
Text.set(battery_draw.value, cr, 'A / C')
ScalePlot.update(battery_draw.plot, cr, 0)
else
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 power = current * voltage * 0.000000000001
Text.set(battery_draw.value, cr, util.precision_round_to_string(power, 3)..' W')
ScalePlot.update(battery_draw.plot, cr, power)
end
end
local draw = function(cr, current_interface, update_frequency, ac_active)
__update(cr, update_frequency, ac_active)
if current_interface == 0 then
Text.draw(header.text, cr)
Line.draw(header.underline, cr)
TextColumn.draw(pp01.labels, cr)
TextColumn.draw(pp01.values, cr)
Line.draw(separator, cr)
Text.draw(pkg0.label, cr)
Text.draw(pkg0.value, cr)
ScalePlot.draw(pkg0.plot, cr)
Text.draw(dram.label, cr)
Text.draw(dram.value, cr)
ScalePlot.draw(dram.plot, cr)
Text.draw(battery_draw.label, cr)
Text.draw(battery_draw.value, cr)
ScalePlot.draw(battery_draw.plot, cr)
end
end
return draw

View File

@ -2,7 +2,6 @@ local Widget = require 'Widget'
local Arc = require 'Arc'
local CompoundDial = require 'CompoundDial'
local CriticalText = require 'CriticalText'
local TextColumn = require 'TextColumn'
local Text = require 'Text'
local Line = require 'Line'
local LabelPlot = require 'LabelPlot'
@ -10,136 +9,144 @@ local Table = require 'Table'
local util = require 'util'
local schema = require 'default_patterns'
local MODULE_Y = 375
local CORETEMP_PATH = '/sys/devices/platform/coretemp.0/hwmon/hwmon%i/%s'
local CPU_CONKY = {
'${cpu cpu1}',
'${cpu cpu2}',
'${cpu cpu3}',
'${cpu cpu4}',
}
local MODULE_Y = 636
local NUM_PHYSICAL_CORES = 4
local NUM_PHYSICAL_CORE_THREADS = 2
local NUM_ROWS = 5
local TABLE_CONKY = {{}, {}, {}}
for r = 1, 5 do
for r = 1, NUM_ROWS do
TABLE_CONKY[1][r] = '${top name '..r..'}'
TABLE_CONKY[2][r] = '${top pid '..r..'}'
TABLE_CONKY[3][r] = '${top cpu '..r..'}'
end
--construction params
local DIAL_INNER_RADIUS = 28
local DIAL_OUTER_RADIUS = 48
local DIAL_INNER_RADIUS = 30
local DIAL_OUTER_RADIUS = 42
local DIAL_SPACING = 1
local TEXT_Y_OFFSET = 15
local TEXT_LEFT_X_OFFSET = 25
local TEXT_SPACING = 20
local SEPARATOR_SPACING = 15
local PLOT_SECTION_BREAK = 20
local SEPARATOR_SPACING = 20
local PLOT_SECTION_BREAK = 23
local PLOT_HEIGHT = 56
local TABLE_SECTION_BREAK = 20
local TABLE_HEIGHT = 114
local CREATE_CORE = function(cores, id, x, y)
local conky_threads = {}
for c = 0, NUM_PHYSICAL_CORES * NUM_PHYSICAL_CORE_THREADS - 1 do
if util.read_file('/sys/devices/system/cpu/cpu'..c..'/topology/core_id', nil, '*n') == id then
table.insert(conky_threads, '${cpu cpu'..c..'}')
end
end
local hwmon_index = -1
while util.read_file(string.format(CORETEMP_PATH, hwmon_index, 'name'), nil, '*l') ~= 'coretemp' do
hwmon_index = hwmon_index + 1
end
cores[id +1] = {
dials = Widget.CompoundDial{
x = x,
y = y,
inner_radius = DIAL_INNER_RADIUS,
outer_radius = DIAL_OUTER_RADIUS,
spacing = DIAL_SPACING,
num_dials = NUM_PHYSICAL_CORE_THREADS,
critical_limit = '>0.8'
},
inner_ring = Widget.Arc{
x = x,
y = y,
radius = DIAL_INNER_RADIUS - 2,
theta0 = 0,
theta1 = 360
},
coretemp_text = Widget.CriticalText{
x = x,
y = y,
x_align = 'center',
y_align = 'center',
append_end = '°C',
critical_limit = '>90'
},
coretemp_path = string.format(CORETEMP_PATH, hwmon_index, 'temp'..(id + 2)..'_input'),
conky_threads = conky_threads
}
end
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "PROCESSOR"
}
local HEADER_BOTTOM_Y = header.bottom_y
local DIAL_X = CONSTRUCTION_GLOBAL.LEFT_X + DIAL_OUTER_RADIUS
local DIAL_Y = HEADER_BOTTOM_Y + DIAL_OUTER_RADIUS
--we assume that this cpu has 4 physical cores with 2 logical each
local cores = {}
local dials = Widget.CompoundDial{
x = DIAL_X,
y = DIAL_Y,
inner_radius = DIAL_INNER_RADIUS,
outer_radius = DIAL_OUTER_RADIUS,
spacing = DIAL_SPACING,
num_dials = 4,
critical_limit = '>0.8'
}
local total_load = Widget.CriticalText{
x = DIAL_X,
y = DIAL_Y,
x_align = 'center',
y_align = 'center',
append_end = '%'
}
for c = 0, NUM_PHYSICAL_CORES - 1 do
local dial_x = CONSTRUCTION_GLOBAL.LEFT_X + DIAL_OUTER_RADIUS + (CONSTRUCTION_GLOBAL.SECTION_WIDTH - 2 * DIAL_OUTER_RADIUS) * c / 3
CREATE_CORE(cores, c, dial_x, HEADER_BOTTOM_Y + DIAL_OUTER_RADIUS)
end
local inner_ring = Widget.Arc{
x = DIAL_X,
y = DIAL_Y,
radius = DIAL_INNER_RADIUS - 2,
theta0 = 0,
theta1 = 360
}
local RIGHT_X = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH
local LINE_1_Y = HEADER_BOTTOM_Y + TEXT_Y_OFFSET
local TEXT_LEFT_X = CONSTRUCTION_GLOBAL.LEFT_X + dials.width + TEXT_LEFT_X_OFFSET
local RIGHT_X = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SIDE_WIDTH
local PROCESS_Y = HEADER_BOTTOM_Y + DIAL_OUTER_RADIUS * 2 + PLOT_SECTION_BREAK
local core = {
labels = Widget.TextColumn{
x = TEXT_LEFT_X,
y = LINE_1_Y,
spacing = TEXT_SPACING,
'Core 0',
'Core 1'
local process = {
labels = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = PROCESS_Y,
text = 'R | S | D | T | Z'
},
temp1 = Widget.CriticalText{
values = Widget.Text{
x = RIGHT_X,
y = LINE_1_Y,
y = PROCESS_Y,
x_align = 'right',
append_end = '°C',
critical_limit = '>86'
},
temp2 = Widget.CriticalText{
x = RIGHT_X,
y = LINE_1_Y + TEXT_SPACING,
x_align = 'right',
append_end = '°C',
critical_limit = '>86'
text_color = schema.blue,
text = '<R.S.D.T.Z>'
}
}
local SEP_Y = LINE_1_Y + TEXT_SPACING + SEPARATOR_SPACING
local SEP_Y = PROCESS_Y + SEPARATOR_SPACING
local separator = Widget.Line{
p1 = {x = TEXT_LEFT_X, y = SEP_Y},
p1 = {x = CONSTRUCTION_GLOBAL.LEFT_X, y = SEP_Y},
p2 = {x = RIGHT_X, y = SEP_Y}
}
local PROCESS_Y = SEP_Y + SEPARATOR_SPACING
local LOAD_Y = SEP_Y + SEPARATOR_SPACING
local process = {
labels = Widget.TextColumn{
x = TEXT_LEFT_X,
y = PROCESS_Y,
spacing = TEXT_SPACING,
'R / S',
'D / T / Z'
local total_load = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = LOAD_Y,
text = 'Total Load'
},
totals = Widget.TextColumn{
value = Widget.CriticalText{
x = RIGHT_X,
y = PROCESS_Y,
spacing = TEXT_SPACING,
y = LOAD_Y,
x_align = 'right',
text_color = schema.blue,
'<proc>',
'<thread>'
append_end = '%',
critical_limit = '>80'
}
}
local PLOT_Y = PLOT_SECTION_BREAK + HEADER_BOTTOM_Y + dials.height
local PLOT_Y = LOAD_Y + PLOT_SECTION_BREAK
local plot = Widget.LabelPlot{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT
}
@ -148,8 +155,9 @@ local TABLE_Y = PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK
local tbl = Widget.Table{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = TABLE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = TABLE_HEIGHT,
num_rows = NUM_ROWS,
'Name',
'PID',
'CPU (%)'
@ -160,40 +168,36 @@ local __update = function(cr)
local char_count = util.char_count
local sum = 0
for i = 1, #CPU_CONKY do
local percent = util.conky_numeric(CPU_CONKY[i]) * 0.01
CompoundDial.set(dials, i, percent)
for c = 1, NUM_PHYSICAL_CORES do
local core = cores[c]
local conky_threads = core.conky_threads
for t = 1, NUM_PHYSICAL_CORE_THREADS do
local percent = util.conky_numeric(conky_threads[t]) * 0.01
CompoundDial.set(core.dials, t, percent)
sum = sum + percent
end
local load_percent = util.round(sum * 0.25, 2)
CriticalText.set(total_load, cr, load_percent * 100)
CriticalText.set(core.temp1, cr, util.round(0.001 * util.read_file(
'/sys/class/thermal/thermal_zone0/temp', nil, '*n')))
CriticalText.set(core.temp2, cr, util.round(0.001 * util.read_file(
'/sys/class/thermal/thermal_zone1/temp', nil, '*n')))
CriticalText.set(core.coretemp_text, cr, util.round(0.001 * util.read_file(core.coretemp_path, nil, '*n')))
end
local process_glob = util.execute_cmd('ps -A -o s')
local running = char_count(process_glob, 'R')
local uninterrupted_sleep = char_count(process_glob, 'D')
local interrupted_sleep = char_count(process_glob, 'S')
local stopped = char_count(process_glob, 'T')
local zombie = char_count(process_glob, 'Z')
--subtract one from running b/c ps will always be "running"
Text.set(process.values, cr, (char_count(process_glob, 'R') - 1)..' | '..
char_count(process_glob, 'S')..' | '..
char_count(process_glob, 'D')..' | '..
char_count(process_glob, 'T')..' | '..
char_count(process_glob, 'Z'))
--subtract one b/c ps will always be "running"
running = running - 1
local totals = process.totals
TextColumn.set(totals, cr, 1, running..' / '..interrupted_sleep)
TextColumn.set(totals, cr, 2, uninterrupted_sleep..' / '..stopped..' / '..zombie)
local load_percent = util.round(sum / NUM_PHYSICAL_CORES / NUM_PHYSICAL_CORE_THREADS, 2)
CriticalText.set(total_load.value, cr, load_percent * 100)
LabelPlot.update(plot, load_percent)
for c = 1, 3 do
local column = TABLE_CONKY[c]
for r = 1, 5 do
for r = 1, NUM_ROWS do
Table.set(tbl, cr, c, r, conky(column[r], '(%S+)'))
end
end
@ -206,18 +210,14 @@ DIAL_INNER_RADIUS = nil
DIAL_OUTER_RADIUS = nil
DIAL_SPACING = nil
TEXT_Y_OFFSET = nil
TEXT_LEFT_X_OFFSET = nil
TEXT_SPACING = nil
SEPARATOR_SPACING = nil
PLOT_SECTION_BREAK = nil
PLOT_HEIGHT = nil
TABLE_SECTION_BREAK = nil
TABLE_HEIGHT = nil
CREATE_CORE = nil
HEADER_BOTTOM_Y = nil
DIAL_X = nil
DIAL_Y = nil
LINE_1_Y = nil
TEXT_LEFT_X = nil
LOAD_Y = nil
RIGHT_X = nil
SEP_Y = nil
PROCESS_Y = nil
@ -230,18 +230,21 @@ local draw = function(cr, current_interface)
if current_interface == 0 then
Text.draw(header.text, cr)
Line.draw(header.underline, cr)
CompoundDial.draw(dials, cr)
Arc.draw(inner_ring, cr)
CriticalText.draw(total_load, cr)
TextColumn.draw(core.labels, cr)
CriticalText.draw(core.temp1, cr)
CriticalText.draw(core.temp2, cr)
for c = 1, NUM_PHYSICAL_CORES do
local core = cores[c]
CompoundDial.draw(core.dials, cr)
Arc.draw(core.inner_ring, cr)
CriticalText.draw(core.coretemp_text, cr)
end
Text.draw(process.labels, cr)
Text.draw(process.values, cr)
Line.draw(separator, cr)
TextColumn.draw(process.labels, cr)
TextColumn.draw(process.totals, cr)
Text.draw(total_load.label, cr)
CriticalText.draw(total_load.value, cr)
LabelPlot.draw(plot, cr)

View File

@ -5,8 +5,6 @@ local ScalePlot = require 'ScalePlot'
local util = require 'util'
local schema = require 'default_patterns'
local MODULE_Y = 165
local _TONUMBER = tonumber
local _STRING_MATCH = string.match
@ -47,19 +45,19 @@ local __io_label_function = function(bytes)
end
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "INPUT / OUTPUT"
}
local HEADER_BOTTOM_Y = header.bottom_y
local RIGHT_X = CONSTRUCTION_GLOBAL.RIGHT_X + CONSTRUCTION_GLOBAL.SIDE_WIDTH
local RIGHT_X = CONSTRUCTION_GLOBAL.CENTER_LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH
local READS_PLOT_Y = header.bottom_y + PLOT_SEC_BREAK
local reads = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = HEADER_BOTTOM_Y,
text = 'Reads',
},
@ -71,9 +69,9 @@ local reads = {
text_color = schema.blue
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = READS_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __io_label_function,
}
@ -84,7 +82,7 @@ local WRITES_PLOT_Y = WRITE_Y + PLOT_SEC_BREAK
local writes = {
label = Widget.Text{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = WRITE_Y,
text = 'Writes',
},
@ -96,9 +94,9 @@ local writes = {
text_color = schema.blue
},
plot = Widget.ScalePlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = WRITES_PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT,
y_label_func = __io_label_function,
}
@ -106,7 +104,6 @@ local writes = {
Widget = nil
schema = nil
MODULE_Y = nil
PLOT_SEC_BREAK = nil
PLOT_HEIGHT = nil
HEADER_BOTTOM_Y = nil

View File

@ -19,7 +19,7 @@ local TEXT_SPACING = 20
local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "SYSTEM"
}
@ -33,7 +33,7 @@ local labels = Widget.TextColumn{
'Last Sync'
}
local info = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = CONSTRUCTION_GLOBAL.LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = header.bottom_y,
spacing = TEXT_SPACING,
x_align = 'right',

View File

@ -16,21 +16,21 @@ local _OS_EXECUTE = os.execute
local TIME_FORMAT = '%-I:%M %p'
local DATE_FORMAT = '%A'
local SECTIONS = 6
local SECTIONS = 8
local WEATHER_UPDATE_INTERVAL = 900
local WEATHER_PATH = '/tmp/weather.json'
local ICON_PATH = CONSTRUCTION_GLOBAL.ABS_PATH .. '/images/weather/'
local RECENTLY_UPDATED_PATH = '/tmp/weather_recently_updated'
local NA = "N/A"
local NA = 'N/A'
local NA_IMAGE_PATH = ICON_PATH .. 'na.png'
--construction params
local SPACING = 20
local HEADER_PAD = 20
local ICON_PAD = 20
local ICON_SIDE_LENGTH = 65
local TEMP_SECTION_WIDTH = 140
local ICON_SIDE_LENGTH = 75
local TEMP_SECTION_WIDTH = 220
local SECTION_HEIGHT = HEADER_PAD + ICON_SIDE_LENGTH + 30
local __create_side_section = function(x_offset, y_offset, section_table)
@ -46,7 +46,7 @@ local __create_side_section = function(x_offset, y_offset, section_table)
}
current_widget.period = Widget.Text{
x = x_offset + CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = x_offset + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = current_y,
x_align = 'right',
text_color = schema.blue
@ -84,7 +84,7 @@ local __create_side_section = function(x_offset, y_offset, section_table)
}
current_widget.info_column = Widget.TextColumn{
x = x_offset + CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = x_offset + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = current_y + HEADER_PAD + 10,
spacing = SPACING,
x_align = 'right',
@ -99,7 +99,7 @@ local __create_side_section = function(x_offset, y_offset, section_table)
y = current_y + SECTION_HEIGHT - 18
},
p2 = {
x = x_offset + CONSTRUCTION_GLOBAL.SIDE_WIDTH,
x = x_offset + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = current_y + SECTION_HEIGHT - 18
},
line_pattern = schema.mid_grey
@ -113,8 +113,8 @@ local left = {
header = Widget.Header{
x = CONSTRUCTION_GLOBAL.LEFT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
header = "HOURLY FORECAST"
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = 'HOURLY FORECAST'
},
hours = {}
}
@ -125,96 +125,104 @@ __create_side_section(CONSTRUCTION_GLOBAL.LEFT_X, left.header.bottom_y, left.hou
local center = {}
center.header = Widget.Header{
x = CONSTRUCTION_GLOBAL.CENTER_X,
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.CENTER_WIDTH,
header = "CURRENT CONDITIONS"
header = 'CURRENT CONDITIONS'
}
center.current_desc = Widget.Text{
x = CONSTRUCTION_GLOBAL.CENTER_X,
y = center.header.bottom_y,
text_color = schema.blue
x = CONSTRUCTION_GLOBAL.CENTER_LEFT_X,
y = center.header.bottom_y + 8,
text_color = schema.blue,
font_size = 24
}
local CENTER_SPACING = SPACING + 5
local INFO_Y = center.header.bottom_y + CENTER_SPACING
local CENTER_X_1 = CONSTRUCTION_GLOBAL.CENTER_LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH * 0.25
local CENTER_ICON_WIDTH = 120
local CENTER_ICON_Y = center.header.bottom_y + 105 - CENTER_ICON_WIDTH / 2
center.icon = Widget.ScaledImage{
x = CONSTRUCTION_GLOBAL.CENTER_X,
y = INFO_Y,
width = ICON_SIDE_LENGTH,
height = ICON_SIDE_LENGTH
x = CENTER_X_1 - CENTER_ICON_WIDTH / 2,
y = CENTER_ICON_Y,
width = CENTER_ICON_WIDTH,
height = CENTER_ICON_WIDTH
}
local TEXT_1_PAD = 80
local TEXT_1_X = CONSTRUCTION_GLOBAL.CENTER_X + ICON_SIDE_LENGTH + TEXT_1_PAD
local CENTER_X_2 = CONSTRUCTION_GLOBAL.CENTER_LEFT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH * 0.70
local INFO_Y = center.header.bottom_y + 70
center.current_temp = Widget.Text{
x = TEXT_1_X,
y = INFO_Y + 11,
x = CENTER_X_2,
y = INFO_Y,
x_align = 'center',
font_size = 32,
font_size = 48,
text_color = schema.blue
}
center.obs_time = Widget.Text{
x = TEXT_1_X,
y = INFO_Y + 39,
x = CENTER_X_2,
y = INFO_Y + 42,
x_align = 'center',
font_size = 11,
font_size = 12,
}
center.place = Widget.Text{
x = TEXT_1_X,
y = INFO_Y + 57,
x = CENTER_X_2,
y = INFO_Y + 66,
x_align = 'center',
font_size = 11,
font_size = 12,
}
local COLUMN_WIDTH = 189
local LABEL_COLUMN_1_X = TEXT_1_X + TEXT_1_PAD
local COLUMN_PADDING = 15
local CENTER_SPACING = SPACING + 7
center.label_column_1 = Widget.TextColumn{
x = LABEL_COLUMN_1_X,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X,
y = center.header.bottom_y,
spacing = CENTER_SPACING,
font_size = 14,
'Feels Like',
'Dewpoint',
'Sky Coverage',
'Humidity',
'Sky Coverage',
'Visibility',
'Ceiling',
'Precipitation'
}
center.info_column_1 = Widget.TextColumn{
x = LABEL_COLUMN_1_X + COLUMN_WIDTH,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X + (CONSTRUCTION_GLOBAL.SECTION_WIDTH - COLUMN_PADDING) / 2,
y = center.header.bottom_y,
x_align = 'right',
text_color = schema.blue,
spacing = CENTER_SPACING,
num_rows = 5
font_size = 14,
num_rows = 7
}
local LABEL_COLUMN_2_X = LABEL_COLUMN_1_X + COLUMN_WIDTH + 20
center.label_column_2 = Widget.TextColumn{
x = LABEL_COLUMN_2_X,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X + (CONSTRUCTION_GLOBAL.SECTION_WIDTH + COLUMN_PADDING) / 2,
y = center.header.bottom_y,
spacing = CENTER_SPACING,
font_size = 14,
'WindSpd',
'WindGust',
'WindDir',
'Pressure',
'Sunrise',
'Sunset'
'Sunset',
'Light Rate'
}
center.info_column_2 = Widget.TextColumn{
x = LABEL_COLUMN_2_X + COLUMN_WIDTH,
x = CONSTRUCTION_GLOBAL.CENTER_RIGHT_X + CONSTRUCTION_GLOBAL.SECTION_WIDTH,
y = center.header.bottom_y,
x_align = 'right',
text_color = schema.blue,
spacing = CENTER_SPACING,
num_rows = 5
font_size = 14,
num_rows = 7
}
--RIGHT
@ -223,8 +231,8 @@ local right = {
header = Widget.Header{
x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH,
header = "6 DAY FORECAST"
width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = '8 DAY FORECAST'
},
days = {}
}
@ -263,8 +271,9 @@ local __populate_section = function(current_section, cr, desc, period, icon_path
TextColumn.set(current_section.info_column, cr, 3, wind or NA)
end
local __populate_center = function(center_section, cr, desc, icon_path, temp, obs_time, place, feels_like,
dewpoint, coverage, humidity, precip, wind, pressure, visibility, sunrise, sunset)
local __populate_center = function(center_section, cr, desc, icon_path, temp,
obs_time, place, feels_like, dewpoint, humidity, coverage, visibility, ceiling,
precip, wind_spd, wind_gust_spd, wind_dir, pressure, sunrise, sunset, light)
if desc then
Text.set(center_section.current_desc, cr, Text.trim_to_length(desc, 20))
@ -282,17 +291,21 @@ local __populate_center = function(center_section, cr, desc, icon_path, temp, ob
TextColumn.set(info_column_1, cr, 1, feels_like or NA)
TextColumn.set(info_column_1, cr, 2, dewpoint or NA)
TextColumn.set(info_column_1, cr, 3, coverage or NA)
TextColumn.set(info_column_1, cr, 4, humidity or NA)
TextColumn.set(info_column_1, cr, 5, precip or NA)
TextColumn.set(info_column_1, cr, 3, humidity or NA)
TextColumn.set(info_column_1, cr, 4, coverage or NA)
TextColumn.set(info_column_1, cr, 5, visibility or NA)
TextColumn.set(info_column_1, cr, 6, ceiling or NA)
TextColumn.set(info_column_1, cr, 7, precip or NA)
local info_column_2 = center_section.info_column_2
TextColumn.set(info_column_2, cr, 1, wind or NA)
TextColumn.set(info_column_2, cr, 2, pressure or NA)
TextColumn.set(info_column_2, cr, 3, visibility or NA)
TextColumn.set(info_column_2, cr, 4, sunrise or NA)
TextColumn.set(info_column_2, cr, 5, sunset or NA)
TextColumn.set(info_column_2, cr, 1, wind_spd or NA)
TextColumn.set(info_column_2, cr, 2, wind_gust_spd or NA)
TextColumn.set(info_column_2, cr, 3, wind_dir or NA)
TextColumn.set(info_column_2, cr, 4, pressure or NA)
TextColumn.set(info_column_2, cr, 5, sunrise or NA)
TextColumn.set(info_column_2, cr, 6, sunset or NA)
TextColumn.set(info_column_2, cr, 7, light or NA)
end
local __update_interface = function(cr)
@ -359,14 +372,18 @@ local __update_interface = function(cr)
place,
ob.feelslikeF and ob.feelslikeF..'°F',
ob.dewpointF and ob.dewpointF..'°F',
ob.sky and ob.sky..' %',
ob.humidity and ob.humidity..' %',
ob.sky and ob.sky..' %',
ob.visibilityMI and ob.visibilityMI..' mi',
ob.ceilingFT and ob.ceilingFT..' ft',
ob.precipIN and ob.precipIN..' in',
ob.windSpeedMPH and ob.windSpeedMPH..' mph',
ob.windGustMPH and ob.windGustMPH..' mph',
ob.windDirDEG and ob.windDirDEG..' deg',
ob.pressureMB and ob.pressureMB..' mbar',
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..' %'
)
--RIGHT

View File

@ -14,15 +14,19 @@ ob.timestamp,\
ob.tempF,\
ob.dewpointF,\
ob.sky,\
ob.visibilityMI,\
ob.ceilingFT,\
ob.humidity,\
ob.pressureMB,\
ob.windSpeedMPH,\
ob.windGustMPH,\
ob.windDirDEG,\
ob.weather,\
ob.feelslikeF,\
ob.icon,\
ob.sunrise,\
ob.sunset,\
ob.light,\
ob.precipIN"
observations="/observations%3F$o_fields"
@ -37,7 +41,7 @@ periods.windSpeedMPH,\
periods.icon,\
periods.weatherPrimary"
hourly="/forecasts%3Ffilter=4hr%26limit=6%26$h_fields"
hourly="/forecasts%3Ffilter=4hr%26limit=8%26$h_fields"
d_fields="fields=\
periods.timestamp,\
@ -50,7 +54,7 @@ periods.icon,\
periods.windSpeedMPH,\
periods.weatherPrimary"
daily="/forecasts%3Ffrom=tomorrow%26limit=6%26$d_fields"
daily="/forecasts%3Ffrom=tomorrow%26limit=8%26$d_fields"
alerts="/alerts"