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', own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
double_buffer = true, double_buffer = true,
minimum_width = 1377, minimum_width = 1920,
minimum_height = 778, minimum_height = 1080,
draw_shades = false, draw_shades = false,
draw_outline = false, draw_outline = false,

View File

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

View File

@ -20,18 +20,27 @@ package.path = ABS_PATH..'/?.lua;'..
local UPDATE_FREQUENCY = 1 --Hz local UPDATE_FREQUENCY = 1 --Hz
CONSTRUCTION_GLOBAL = { CONSTRUCTION_GLOBAL = {
UPDATE_INTERVAL = 1 / UPDATE_FREQUENCY, UPDATE_INTERVAL = 1 / UPDATE_FREQUENCY,
LEFT_X = 30,
CENTER_X = 376, LEFT_X = 32,
RIGHT_X = 1045, SECTION_WIDTH = 436,
TOP_Y = 21, CENTER_PAD = 20,
SIDE_WIDTH = 300, PANEL_HORZ_SPACING = 10,
SIDE_HEIGHT = 709, PANEL_MARGIN_X = 20,
CENTER_WIDTH = 623, PANEL_MARGIN_Y = 10,
CENTER_HEIGHT = 154,
ABS_PATH = ABS_PATH TOP_Y = 21,
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 ABS_PATH = nil
conky_set_update_interval(CONSTRUCTION_GLOBAL.UPDATE_INTERVAL) conky_set_update_interval(CONSTRUCTION_GLOBAL.UPDATE_INTERVAL)
@ -46,7 +55,9 @@ local Network = require 'Network'
local Processor = require 'Processor' local Processor = require 'Processor'
local FileSystem = require 'FileSystem' local FileSystem = require 'FileSystem'
local Pacman = require 'Pacman' local Pacman = require 'Pacman'
local Power = require 'Power'
local ReadWrite = require 'ReadWrite' local ReadWrite = require 'ReadWrite'
local Graphics = require 'Graphics'
local Memory = require 'Memory' local Memory = require 'Memory'
local Weather = require 'Weather' local Weather = require 'Weather'
@ -106,7 +117,7 @@ function conky_main()
local cw = conky_window local cw = conky_window
if not cw then return end if not cw then return end
--~ print(cw.width, cw.height) ###USE THIS TO GET WIDTH AND HEIGHT OF WINDOW --~ 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) local cr = _CAIRO_CREATE(cs)
updates = updates + 1 updates = updates + 1
@ -114,7 +125,8 @@ function conky_main()
local t1 = updates % (UPDATE_FREQUENCY * 10) local t1 = updates % (UPDATE_FREQUENCY * 10)
local t2 local t2
if using_ac() then local ac = using_ac()
if ac then
t2 = updates % (UPDATE_FREQUENCY * 60) t2 = updates % (UPDATE_FREQUENCY * 60)
else else
t2 = updates % (UPDATE_FREQUENCY * 300) t2 = updates % (UPDATE_FREQUENCY * 300)
@ -128,16 +140,16 @@ function conky_main()
--interface 0 --interface 0
System(cr, current_interface, log_changed) System(cr, current_interface, log_changed)
Network(cr, current_interface, UPDATE_FREQUENCY) Graphics(cr, current_interface)
Processor(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 ReadWrite(cr, current_interface, UPDATE_FREQUENCY)
--~ USB(cr, current_interface) Network(cr, current_interface, UPDATE_FREQUENCY)
--~ Remote(cr, current_interface, t1)
Pacman(cr, current_interface, log_changed)
FileSystem(cr, current_interface, t1)
Power(cr, current_interface, UPDATE_FREQUENCY, ac)
Memory(cr, current_interface)
--interface 1 --interface 1
Weather(cr, current_interface, interface_changed) Weather(cr, current_interface, interface_changed)

View File

@ -16,21 +16,22 @@ local FS_NUM = #FS_PATHS
local FS_REGEX = '^([%d%p]-)(%a+)' local FS_REGEX = '^([%d%p]-)(%a+)'
--construction params --construction params
local MODULE_Y = 165
local SPACING = 20 local SPACING = 20
local TEXT_WIDTH = 200 --~ local TEXT_WIDTH = 220
local BAR_PAD = 20 local BAR_PAD = 100
local header = Widget.Header{ local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.CENTER_X, x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = CONSTRUCTION_GLOBAL.TOP_Y, y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.CENTER_WIDTH, width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "FILE SYSTEMS" header = 'FILE SYSTEMS'
} }
local HEADER_BOTTOM_Y = header.bottom_y local HEADER_BOTTOM_Y = header.bottom_y
local labels = Widget.TextColumn{ local labels = Widget.TextColumn{
x = CONSTRUCTION_GLOBAL.CENTER_X, x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = HEADER_BOTTOM_Y, y = HEADER_BOTTOM_Y,
spacing = SPACING, spacing = SPACING,
'root', 'root',
@ -41,33 +42,35 @@ local labels = Widget.TextColumn{
'lopt' 'lopt'
} }
local totals = {} --~ local totals = {}
for i = 1, FS_NUM do --~ for i = 1, FS_NUM do
totals[i] = Widget.CriticalText{ --~ totals[i] = Widget.CriticalText{
x = CONSTRUCTION_GLOBAL.CENTER_X + TEXT_WIDTH, --~ x = CONSTRUCTION_GLOBAL.RIGHT_X + TEXT_WIDTH,
y = HEADER_BOTTOM_Y + (i - 1) * SPACING, --~ y = HEADER_BOTTOM_Y + (i - 1) * SPACING,
x_align = 'right', --~ x_align = 'right',
text_color = schema.blue, --~ text_color = schema.blue,
} --~ }
end --~ end
local units = {} --~ local units = {}
local conky_used = {} --~ local conky_used = {}
local conky_used_perc = {} local conky_used_perc = {}
for i, v in _PAIRS(FS_PATHS) do for i, v in _PAIRS(FS_PATHS) do
local size, unit = _STRING_MATCH(util.conky('${fs_size '..v..'}'), FS_REGEX) --~ local size, unit = _STRING_MATCH(util.conky('${fs_size '..v..'}'), FS_REGEX)
totals[i].append_end = ' / '..size..' ('..unit..')' --~ totals[i].append_end = ' / '..size..' ('..unit..')'
units[i] = unit --~ units[i] = unit
conky_used[i] = '${fs_used '..v..'}' --~ conky_used[i] = '${fs_used '..v..'}'
conky_used_perc[i] = '${fs_used_perc '..v..'}' conky_used_perc[i] = '${fs_used_perc '..v..'}'
end end
local bars = Widget.CompoundBar{ 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, 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, spacing = SPACING,
num_bars = FS_NUM, num_bars = FS_NUM,
critical_limit = '>0.8' critical_limit = '>0.8'
@ -85,11 +88,11 @@ HEADER_BOTTOM_Y = nil
local __update = function(cr) local __update = function(cr)
for i = 1, FS_NUM do 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 percent = util.conky_numeric(conky_used_perc[i])
local force = 1 --~ local force = 1
if percent > 80 then force = 0 end --~ if percent > 80 then force = 0 end
CriticalText.set(totals[i], cr, util.precision_convert_bytes(value, unit, units[i], 3), force) --~ CriticalText.set(totals[i], cr, util.precision_convert_bytes(value, unit, units[i], 3), force)
CompoundBar.set(bars, i, percent * 0.01) CompoundBar.set(bars, i, percent * 0.01)
end end
end end
@ -105,9 +108,9 @@ local draw = function(cr, current_interface, trigger)
Text.draw(header.text, cr) Text.draw(header.text, cr)
Line.draw(header.underline, cr) Line.draw(header.underline, cr)
TextColumn.draw(labels, cr) TextColumn.draw(labels, cr)
for i = 1, FS_NUM do --~ for i = 1, FS_NUM do
CriticalText.draw(totals[i], cr) --~ CriticalText.draw(totals[i], cr)
end --~ end
CompoundBar.draw(bars, cr) CompoundBar.draw(bars, cr)
end end
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 _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 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{ local header = Widget.Header{
x = CONSTRUCTION_GLOBAL.RIGHT_X, x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = MODULE_Y, y = MODULE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH, width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
header = "MEMORY" header = "MEMORY"
} }
@ -86,7 +86,7 @@ local inner_ring = Widget.Arc{
local LINE_1_Y = HEADER_BOTTOM_Y + TEXT_Y_OFFSET 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 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= { local swap= {
label = Widget.Text{ label = Widget.Text{
@ -129,7 +129,7 @@ local PLOT_Y = PLOT_SECTION_BREAK + HEADER_BOTTOM_Y + DIAL_RADIUS * 2
local plot = Widget.LabelPlot{ local plot = Widget.LabelPlot{
x = CONSTRUCTION_GLOBAL.RIGHT_X, x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = PLOT_Y, y = PLOT_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH, width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = PLOT_HEIGHT height = PLOT_HEIGHT
} }
@ -138,7 +138,7 @@ local TABLE_Y = PLOT_Y + PLOT_HEIGHT + TABLE_SECTION_BREAK
local tbl = Widget.Table{ local tbl = Widget.Table{
x = CONSTRUCTION_GLOBAL.RIGHT_X, x = CONSTRUCTION_GLOBAL.RIGHT_X,
y = TABLE_Y, y = TABLE_Y,
width = CONSTRUCTION_GLOBAL.SIDE_WIDTH, width = CONSTRUCTION_GLOBAL.SECTION_WIDTH,
height = TABLE_HEIGHT, height = TABLE_HEIGHT,
'Name', 'Name',
'PID', 'PID',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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