From 3ca319bd7eb90bcd1744e996f8db4eb81dd1bcc7 Mon Sep 17 00:00:00 2001 From: petrucci4prez Date: Thu, 20 Jul 2017 00:49:24 -0400 Subject: [PATCH] make widget and patterns global vars so we can control their destruction easier through main.lua --- drawing/FileSystem.lua | 9 ++---- drawing/Graphics.lua | 60 +++++++++++++++++++--------------------- drawing/Memory.lua | 30 +++++++++----------- drawing/Network.lua | 22 ++++++--------- drawing/Pacman.lua | 12 +++----- drawing/Power.lua | 36 +++++++++++------------- drawing/Processor.lua | 28 ++++++++----------- drawing/ReadWrite.lua | 22 ++++++--------- drawing/System.lua | 12 +++----- drawing/Weather.lua | 63 +++++++++++++++++++----------------------- main.lua | 13 +++++---- 11 files changed, 135 insertions(+), 172 deletions(-) diff --git a/drawing/FileSystem.lua b/drawing/FileSystem.lua index 39bd7a2..942824e 100644 --- a/drawing/FileSystem.lua +++ b/drawing/FileSystem.lua @@ -1,4 +1,3 @@ -local Widget = require 'Widget' local Text = require 'Text' local Line = require 'Line' local TextColumn = require 'TextColumn' @@ -14,14 +13,14 @@ local _BAR_PAD_ = 100 local FS_NUM = #_FS_PATHS_ -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.RIGHT_X, y = _MODULE_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, header = 'FILE SYSTEMS' } -local labels = Widget.TextColumn{ +local labels = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.RIGHT_X, y = header.bottom_y, spacing = _SPACING_, @@ -39,7 +38,7 @@ for i, v in pairs(_FS_PATHS_) do conky_used_perc[i] = '${fs_used_perc '..v..'}' end -local bars = Widget.CompoundBar{ +local bars = _G_Widget_.CompoundBar{ x = _G_INIT_DATA_.RIGHT_X + _BAR_PAD_, y = header.bottom_y, length = _G_INIT_DATA_.SECTION_WIDTH - _BAR_PAD_, @@ -48,8 +47,6 @@ local bars = Widget.CompoundBar{ critical_limit = '>0.8' } -Widget = nil - _SPACING_ = nil _BAR_PAD_ = nil _FS_PATHS_ = nil diff --git a/drawing/Graphics.lua b/drawing/Graphics.lua index 35c95ee..b32ff77 100644 --- a/drawing/Graphics.lua +++ b/drawing/Graphics.lua @@ -1,11 +1,9 @@ -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 Patterns = require 'Patterns' local __tonumber = tonumber local __string_find = string.find @@ -17,7 +15,7 @@ local _TEXT_SPACING_ = 20 local _PLOT_SEC_BREAK_ = 20 local _PLOT_HEIGHT_ = 56 -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.LEFT_X, y = _MODULE_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -27,23 +25,23 @@ local header = Widget.Header{ local _RIGHT_X_ = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH local status = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = header.bottom_y, text = 'Status' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = header.bottom_y, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' } } local _SEP_Y_1_ = header.bottom_y + _SEPARATOR_SPACING_ -local separator1 = Widget.Line{ +local separator1 = _G_Widget_.Line{ p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_1_}, p2 = {x = _RIGHT_X_, y = _SEP_Y_1_} } @@ -51,16 +49,16 @@ local separator1 = Widget.Line{ local _INTERNAL_TEMP_Y_ = _SEP_Y_1_ + _SEPARATOR_SPACING_ local internal_temp = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _INTERNAL_TEMP_Y_, text = 'Internal Temperature' }, - value = Widget.CriticalText{ + value = _G_Widget_.CriticalText{ x = _RIGHT_X_, y = _INTERNAL_TEMP_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' } } @@ -68,23 +66,23 @@ local internal_temp = { local _PCI_UTIL_Y_ = _INTERNAL_TEMP_Y_ + _TEXT_SPACING_ local pci_util = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _PCI_UTIL_Y_, text = 'PCI Utilization' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = _PCI_UTIL_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' } } local _SEP_Y_2_ = _PCI_UTIL_Y_ + _SEPARATOR_SPACING_ -local separator2 = Widget.Line{ +local separator2 = _G_Widget_.Line{ p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_2_}, p2 = {x = _RIGHT_X_, y = _SEP_Y_2_} } @@ -92,26 +90,26 @@ local separator2 = Widget.Line{ local _CLOCK_SPEED_Y_ = _SEP_Y_2_ + _SEPARATOR_SPACING_ local clock_speed = { - labels = Widget.TextColumn{ + labels = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.LEFT_X, y = _CLOCK_SPEED_Y_, spacing = _TEXT_SPACING_, 'GPU Clock Speed', 'Memory Clock Speed' }, - values = Widget.TextColumn{ + values = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH, y = _CLOCK_SPEED_Y_, spacing = _TEXT_SPACING_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, num_rows = 2 } } local _SEP_Y_3_ = _CLOCK_SPEED_Y_ + _TEXT_SPACING_ * 2 -local separator3 = Widget.Line{ +local separator3 = _G_Widget_.Line{ p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_3_}, p2 = {x = _RIGHT_X_, y = _SEP_Y_3_} } @@ -119,19 +117,19 @@ local separator3 = Widget.Line{ local _GPU_UTIL_Y_ = _SEP_Y_3_ + _SEPARATOR_SPACING_ local gpu_util = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _GPU_UTIL_Y_, text = 'GPU Utilization' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = _GPU_UTIL_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' }, - plot = Widget.LabelPlot{ + plot = _G_Widget_.LabelPlot{ x = _G_INIT_DATA_.LEFT_X, y = _GPU_UTIL_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -142,19 +140,19 @@ local gpu_util = { local _MEM_UTIL_Y_ = _GPU_UTIL_Y_ + _PLOT_HEIGHT_ + _PLOT_SEC_BREAK_ * 2 local mem_util = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _MEM_UTIL_Y_, text = 'Memory Utilization' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = _MEM_UTIL_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' }, - plot = Widget.LabelPlot{ + plot = _G_Widget_.LabelPlot{ x = _G_INIT_DATA_.LEFT_X, y = _MEM_UTIL_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -165,19 +163,19 @@ local mem_util = { local _VID_UTIL_Y_ = _MEM_UTIL_Y_ + _PLOT_HEIGHT_ + _PLOT_SEC_BREAK_ * 2 local vid_util = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _VID_UTIL_Y_, text = 'Video Utilization' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = _VID_UTIL_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' }, - plot = Widget.LabelPlot{ + plot = _G_Widget_.LabelPlot{ x = _G_INIT_DATA_.LEFT_X, y = _VID_UTIL_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -272,8 +270,6 @@ local update = function(cr) end end -Widget = nil -Patterns = nil _MODULE_Y_ = nil _SEPARATOR_SPACING_ = nil _TEXT_SPACING_ = nil diff --git a/drawing/Memory.lua b/drawing/Memory.lua index 3d04c89..9152db3 100644 --- a/drawing/Memory.lua +++ b/drawing/Memory.lua @@ -1,4 +1,3 @@ -local Widget = require 'Widget' local Arc = require 'Arc' local Dial = require 'Dial' local CriticalText = require 'CriticalText' @@ -8,7 +7,6 @@ local Line = require 'Line' local LabelPlot = require 'LabelPlot' local Table = require 'Table' local Util = require 'Util' -local Patterns = require 'Patterns' local __string_match = string.match local __cairo_path_destroy = cairo_path_destroy @@ -42,7 +40,7 @@ for r = 1, NUM_ROWS do TABLE_CONKY[3][r] = '${top_mem mem '..r..'}' end -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.RIGHT_X, y = _MODULE_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -55,22 +53,22 @@ local DIAL_THETA_1 = math.rad(360) local DIAL_X = _G_INIT_DATA_.RIGHT_X + DIAL_RADIUS + _DIAL_THICKNESS_ / 2 local DIAL_Y = header.bottom_y + DIAL_RADIUS + _DIAL_THICKNESS_ / 2 -local dial = Widget.Dial{ +local dial = _G_Widget_.Dial{ x = DIAL_X, y = DIAL_Y, radius = DIAL_RADIUS, thickness = _DIAL_THICKNESS_, critical_limit = '>0.8' } -local cache_arc = Widget.Arc{ +local cache_arc = _G_Widget_.Arc{ x = DIAL_X, y = DIAL_Y, radius = DIAL_RADIUS, thickness = _DIAL_THICKNESS_, - arc_pattern = Patterns.PURPLE_ROUNDED + arc_pattern = _G_Patterns_.PURPLE_ROUNDED } -local total_used = Widget.CriticalText{ +local total_used = _G_Widget_.CriticalText{ x = DIAL_X, y = DIAL_Y, x_align = 'center', @@ -78,7 +76,7 @@ local total_used = Widget.CriticalText{ append_end = '%' } -local inner_ring = Widget.Arc{ +local inner_ring = _G_Widget_.Arc{ x = DIAL_X, y = DIAL_Y, radius = DIAL_RADIUS - _DIAL_THICKNESS_ / 2 - 2, @@ -91,13 +89,13 @@ local _TEXT_LEFT_X_ = _G_INIT_DATA_.RIGHT_X + DIAL_RADIUS * 2 + _TEXT_LEFT_X_OFF local _RIGHT_X_ = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH local swap= { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _TEXT_LEFT_X_, y = _LINE_1_Y_, spacing = _TEXT_SPACING_, text = 'Swap Usage' }, - percent = Widget.CriticalText{ + percent = _G_Widget_.CriticalText{ x = _RIGHT_X_, y = _LINE_1_Y_, x_align = 'right', @@ -106,7 +104,7 @@ local swap= { } local cache = { - labels = Widget.TextColumn{ + labels = _G_Widget_.TextColumn{ x = _TEXT_LEFT_X_, y = _LINE_1_Y_ + _TEXT_SPACING_, spacing = _TEXT_SPACING_, @@ -114,12 +112,12 @@ local cache = { 'Buffers', 'Kernel Slab' }, - percents = Widget.TextColumn{ + percents = _G_Widget_.TextColumn{ x = _RIGHT_X_, y = _LINE_1_Y_ + _TEXT_SPACING_, x_align = 'right', append_end = ' %', - text_color = Patterns.PURPLE, + text_color = _G_Patterns_.PURPLE, '', '', '' @@ -128,14 +126,14 @@ local cache = { local _PLOT_Y_ = _PLOT_SECTION_BREAK_ + header.bottom_y + DIAL_RADIUS * 2 -local plot = Widget.LabelPlot{ +local plot = _G_Widget_.LabelPlot{ x = _G_INIT_DATA_.RIGHT_X, y = _PLOT_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, height = _PLOT_HEIGHT_ } -local tbl = Widget.Table{ +local tbl = _G_Widget_.Table{ x = _G_INIT_DATA_.RIGHT_X, y = _PLOT_Y_ + _PLOT_HEIGHT_ + _TABLE_SECTION_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -184,8 +182,6 @@ local update = function(cr) end end -Widget = nil -Patterns = nil _MODULE_Y_ = nil _DIAL_THICKNESS_ = nil _DIAL_SPACING_ = nil diff --git a/drawing/Network.lua b/drawing/Network.lua index c9e3c50..2f4f886 100644 --- a/drawing/Network.lua +++ b/drawing/Network.lua @@ -1,9 +1,7 @@ -local Widget = require 'Widget' local Text = require 'Text' local Line = require 'Line' local ScalePlot = require 'ScalePlot' local Util = require 'Util' -local Patterns = require 'Patterns' local __string_gmatch = string.gmatch @@ -20,7 +18,7 @@ local network_label_function = function(bytes) return Util.round_to_string(converted, precision)..' '..new_unit..'/s' end -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.CENTER_RIGHT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -30,18 +28,18 @@ local header = Widget.Header{ local _RIGHT_X_ = _G_INIT_DATA_.CENTER_RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH local dnload = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.CENTER_RIGHT_X, y = header.bottom_y, text = 'Download', }, - speed = Widget.Text{ + speed = _G_Widget_.Text{ x = _RIGHT_X_, y = header.bottom_y, x_align = 'right', - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.CENTER_RIGHT_X, y = header.bottom_y + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -53,18 +51,18 @@ local dnload = { local _UPLOAD_Y_ = header.bottom_y + _PLOT_HEIGHT_ + _PLOT_SEC_BREAK_ * 2 local upload = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.CENTER_RIGHT_X, y = _UPLOAD_Y_, text = 'Upload', }, - speed = Widget.Text{ + speed = _G_Widget_.Text{ x = _RIGHT_X_, y = _UPLOAD_Y_, x_align = 'right', - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.CENTER_RIGHT_X, y = _UPLOAD_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -127,8 +125,6 @@ local update = function(cr, update_frequency) ScalePlot.update(upload.plot, cr, uspeed) end -Widget = nil -Patterns = nil _PLOT_SEC_BREAK_ = nil _PLOT_HEIGHT_ = nil _RIGHT_X_ = nil diff --git a/drawing/Pacman.lua b/drawing/Pacman.lua index 936c052..3d33018 100644 --- a/drawing/Pacman.lua +++ b/drawing/Pacman.lua @@ -1,9 +1,7 @@ -local Widget = require 'Widget' local Text = require 'Text' local Line = require 'Line' local TextColumn = require 'TextColumn' local Util = require 'Util' -local Patterns = require 'Patterns' local PACMAN_TABLE = { 'pacman -Qq', @@ -15,14 +13,14 @@ local PACMAN_TABLE = { local _TEXT_SPACING_ = 20 -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.RIGHT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.SECTION_WIDTH, header = 'PACMAN' } -local labels = Widget.TextColumn{ +local labels = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.RIGHT_X, y = header.bottom_y, spacing = _TEXT_SPACING_, @@ -32,17 +30,15 @@ local labels = Widget.TextColumn{ 'Orphaned', 'Local' } -local info = Widget.TextColumn{ +local info = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH, y = header.bottom_y, spacing = _TEXT_SPACING_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, num_rows = 5 } -Widget = nil -Patterns = nil _TEXT_SPACING_ = nil local update = function(cr) diff --git a/drawing/Power.lua b/drawing/Power.lua index 85aeff9..e5bbbeb 100644 --- a/drawing/Power.lua +++ b/drawing/Power.lua @@ -1,10 +1,8 @@ -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 Patterns = require 'Patterns' local _MODULE_Y_ = 328 local _SEPARATOR_SPACING_ = 20 @@ -22,7 +20,7 @@ local calculate_power = function(cr, prev_cnt, cnt, update_frequency) end end -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.RIGHT_X, y = _MODULE_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -32,19 +30,19 @@ local header = Widget.Header{ local _RIGHT_X_ = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH local pp01 = { - labels = Widget.TextColumn{ + labels = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.RIGHT_X, y = header.bottom_y, spacing = _TEXT_SPACING_, 'Core', 'iGPU' }, - values = Widget.TextColumn{ + values = _G_Widget_.TextColumn{ x = _RIGHT_X_, y = header.bottom_y, spacing = _TEXT_SPACING_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, append_end = ' W', num_rows = 2 } @@ -52,7 +50,7 @@ local pp01 = { local _SEP_Y_ = header.bottom_y + _TEXT_SPACING_ + _SEPARATOR_SPACING_ -local separator = Widget.Line{ +local separator = _G_Widget_.Line{ p1 = {x = _G_INIT_DATA_.RIGHT_X, y = _SEP_Y_}, p2 = {x = _RIGHT_X_, y = _SEP_Y_} } @@ -60,20 +58,20 @@ local separator = Widget.Line{ local _PKG0_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_ local pkg0 = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.RIGHT_X, y = _PKG0_Y_, text = 'PKG 0' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = _PKG0_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '', append_end = ' W' }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.RIGHT_X, y = _PKG0_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -85,20 +83,20 @@ local pkg0 = { local _DRAM_Y_ = _PKG0_Y_ + _PLOT_SEC_BREAK_ * 2 + _PLOT_HEIGHT_ local dram = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.RIGHT_X, y = _DRAM_Y_, text = 'DRAM' }, - value = Widget.Text{ + value = _G_Widget_.Text{ x = _RIGHT_X_, y = _DRAM_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '', append_end = ' W' }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.RIGHT_X, y = _DRAM_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -110,18 +108,18 @@ local dram = { local _BATTERY_DRAW_Y_ = _DRAM_Y_ + _PLOT_SEC_BREAK_ * 2 + _PLOT_HEIGHT_ local battery_draw = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.RIGHT_X, y = _BATTERY_DRAW_Y_, spacing = _TEXT_SPACING_, text = 'Battery Draw' }, - value = Widget.CriticalText{ + value = _G_Widget_.CriticalText{ x = _RIGHT_X_, y = _BATTERY_DRAW_Y_, x_align = 'right', }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.RIGHT_X, y = _BATTERY_DRAW_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -179,8 +177,6 @@ local update = function(cr, update_frequency, is_using_ac) end end -Widget = nil -Patterns = nil _MODULE_Y_ = nil _SEPARATOR_SPACING_ = nil _TEXT_SPACING_ = nil diff --git a/drawing/Processor.lua b/drawing/Processor.lua index 50cb445..6c88251 100644 --- a/drawing/Processor.lua +++ b/drawing/Processor.lua @@ -1,4 +1,3 @@ -local Widget = require 'Widget' local Arc = require 'Arc' local CompoundDial = require 'CompoundDial' local CriticalText = require 'CriticalText' @@ -7,7 +6,6 @@ local Line = require 'Line' local LabelPlot = require 'LabelPlot' local Table = require 'Table' local Util = require 'Util' -local Patterns = require 'Patterns' local CORETEMP_PATH = '/sys/devices/platform/coretemp.0/hwmon/hwmon%i/%s' @@ -49,7 +47,7 @@ local _create_core_ = function(cores, id, x, y) end cores[id +1] = { - dials = Widget.CompoundDial{ + dials = _G_Widget_.CompoundDial{ x = x, y = y, inner_radius = _DIAL_INNER_RADIUS_, @@ -58,14 +56,14 @@ local _create_core_ = function(cores, id, x, y) num_dials = NUM_THREADS_PER_CORE, critical_limit = '>0.8' }, - inner_ring = Widget.Arc{ + inner_ring = _G_Widget_.Arc{ x = x, y = y, radius = _DIAL_INNER_RADIUS_ - 2, theta0 = 0, theta1 = 360 }, - coretemp_text = Widget.CriticalText{ + coretemp_text = _G_Widget_.CriticalText{ x = x, y = y, x_align = 'center', @@ -78,7 +76,7 @@ local _create_core_ = function(cores, id, x, y) } end -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.LEFT_X, y = _MODULE_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -100,23 +98,23 @@ local _RIGHT_X_ = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH local _PROCESS_Y_ = header.bottom_y + _DIAL_OUTER_RADIUS_ * 2 + _PLOT_SECTION_BREAK_ local process = { - labels = Widget.Text{ + labels = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _PROCESS_Y_, text = 'R | S | D | T | Z' }, - values = Widget.Text{ + values = _G_Widget_.Text{ x = _RIGHT_X_, y = _PROCESS_Y_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, text = '' } } local _SEP_Y_ = _PROCESS_Y_ + _SEPARATOR_SPACING_ -local separator = Widget.Line{ +local separator = _G_Widget_.Line{ p1 = {x = _G_INIT_DATA_.LEFT_X, y = _SEP_Y_}, p2 = {x = _RIGHT_X_, y = _SEP_Y_} } @@ -124,12 +122,12 @@ local separator = Widget.Line{ local _LOAD_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_ local total_load = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.LEFT_X, y = _LOAD_Y_, text = 'Total Load' }, - value = Widget.CriticalText{ + value = _G_Widget_.CriticalText{ x = _RIGHT_X_, y = _LOAD_Y_, x_align = 'right', @@ -140,14 +138,14 @@ local total_load = { local _PLOT_Y_ = _LOAD_Y_ + _PLOT_SECTION_BREAK_ -local plot = Widget.LabelPlot{ +local plot = _G_Widget_.LabelPlot{ x = _G_INIT_DATA_.LEFT_X, y = _PLOT_Y_, width = _G_INIT_DATA_.SECTION_WIDTH, height = _PLOT_HEIGHT_ } -local tbl = Widget.Table{ +local tbl = _G_Widget_.Table{ x = _G_INIT_DATA_.LEFT_X, y = _PLOT_Y_ + _PLOT_HEIGHT_ + _TABLE_SECTION_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -198,8 +196,6 @@ local update = function(cr) end end -Widget = nil -Patterns = nil _MODULE_Y_ = nil _DIAL_INNER_RADIUS_ = nil _DIAL_OUTER_RADIUS_ = nil diff --git a/drawing/ReadWrite.lua b/drawing/ReadWrite.lua index 4a8cfda..b33353d 100644 --- a/drawing/ReadWrite.lua +++ b/drawing/ReadWrite.lua @@ -1,9 +1,7 @@ -local Widget = require 'Widget' local Text = require 'Text' local Line = require 'Line' local ScalePlot = require 'ScalePlot' local Util = require 'Util' -local Patterns = require 'Patterns' local __tonumber = tonumber local __string_match = string.match @@ -49,7 +47,7 @@ local io_label_function = function(bytes) return Util.round_to_string(converted, precision)..' '..new_unit..'/s' end -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -59,19 +57,19 @@ local header = Widget.Header{ local _RIGHT_X_ = _G_INIT_DATA_.CENTER_LEFT_X + _G_INIT_DATA_.SECTION_WIDTH local reads = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = header.bottom_y, text = 'Reads', }, - rate = Widget.Text{ + rate = _G_Widget_.Text{ x = _RIGHT_X_, y = header.bottom_y, x_align = 'right', append_end=' B/s', - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = header.bottom_y + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -83,19 +81,19 @@ local reads = { local _WRITE_Y_ = header.bottom_y + _PLOT_HEIGHT_ + _PLOT_SEC_BREAK_ * 2 local writes = { - label = Widget.Text{ + label = _G_Widget_.Text{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = _WRITE_Y_, text = 'Writes', }, - rate = Widget.Text{ + rate = _G_Widget_.Text{ x = _RIGHT_X_, y = _WRITE_Y_, x_align = 'right', append_end =' B/s', - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE }, - plot = Widget.ScalePlot{ + plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = _WRITE_Y_ + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -104,8 +102,6 @@ local writes = { } } -Widget = nil -Patterns = nil _PLOT_SEC_BREAK_ = nil _PLOT_HEIGHT_ = nil _RIGHT_X_ = nil diff --git a/drawing/System.lua b/drawing/System.lua index eb08ba6..960d9c2 100644 --- a/drawing/System.lua +++ b/drawing/System.lua @@ -1,9 +1,7 @@ -local Widget = require 'Widget' local Text = require 'Text' local Line = require 'Line' local TextColumn = require 'TextColumn' local Util = require 'Util' -local Patterns = require 'Patterns' local __string_match = string.match @@ -14,14 +12,14 @@ local extract_date = function(cmd) return mm_dd..'-'..yyyy end -local header = Widget.Header{ +local header = _G_Widget_.Header{ x = _G_INIT_DATA_.LEFT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.SECTION_WIDTH, header = 'SYSTEM' } -local labels = Widget.TextColumn{ +local labels = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.LEFT_X, y = header.bottom_y, spacing = _TEXT_SPACING_, @@ -30,20 +28,18 @@ local labels = Widget.TextColumn{ 'Last Upgrade', 'Last Sync' } -local info = Widget.TextColumn{ +local info = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.LEFT_X + _G_INIT_DATA_.SECTION_WIDTH, y = header.bottom_y, spacing = _TEXT_SPACING_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, Util.conky('$kernel'), '', '', '' } -Widget = nil -Patterns = nil _TEXT_SPACING_ = nil local draw = function(cr, current_interface, log_is_changed) diff --git a/drawing/Weather.lua b/drawing/Weather.lua index a0ac4ba..8ec6711 100644 --- a/drawing/Weather.lua +++ b/drawing/Weather.lua @@ -1,11 +1,9 @@ -local Widget = require 'Widget' local Text = require 'Text' local Line = require 'Line' local TextColumn = require 'TextColumn' local ScaledImage = require 'ScaledImage' local Util = require 'Util' local Json = require 'Json' -local Patterns = require 'Patterns' local __string_match = string.match local __string_sub = string.sub @@ -36,42 +34,42 @@ local create_side_rows = function(side_rows_x, side_rows_y, side_rows_tbl) local current_row = side_rows_tbl[i] local current_row_y = side_rows_y + (i - 1) * _SECTION_HEIGHT_ - current_row.desc = Widget.Text{ + current_row.desc = _G_Widget_.Text{ x = side_rows_x, y = current_row_y, - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, } - current_row.period = Widget.Text{ + current_row.period = _G_Widget_.Text{ x = side_rows_x + _G_INIT_DATA_.SECTION_WIDTH, y = current_row_y, x_align = 'right', - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE } - current_row.icon = Widget.ScaledImage{ + current_row.icon = _G_Widget_.ScaledImage{ x = side_rows_x, y = current_row_y + _HEADER_PAD_, width = _ICON_SIDE_LENGTH_, height = _ICON_SIDE_LENGTH_ } - current_row.temp1 = Widget.Text{ + current_row.temp1 = _G_Widget_.Text{ x = side_rows_x + _ICON_SIDE_LENGTH_ + _TEMP_SECTION_WIDTH_ / 2, y = current_row_y + _HEADER_PAD_ + 25, x_align = 'center', font_size = 28, - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE } - current_row.temp2 = Widget.Text{ + current_row.temp2 = _G_Widget_.Text{ x = side_rows_x + _ICON_SIDE_LENGTH_ + _TEMP_SECTION_WIDTH_ / 2, y = current_row_y + _HEADER_PAD_ + 55, x_align = 'center', font_size = 11 } - current_row.label_column = Widget.TextColumn{ + current_row.label_column = _G_Widget_.TextColumn{ x = side_rows_x + _ICON_SIDE_LENGTH_ + _TEMP_SECTION_WIDTH_, y = current_row_y + _HEADER_PAD_ + 15, spacing = _SPACING_, @@ -80,17 +78,17 @@ local create_side_rows = function(side_rows_x, side_rows_y, side_rows_tbl) 'W' } - current_row.info_column = Widget.TextColumn{ + current_row.info_column = _G_Widget_.TextColumn{ x = side_rows_x + _G_INIT_DATA_.SECTION_WIDTH, y = current_row_y + _HEADER_PAD_ + 15, spacing = _SPACING_, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, num_rows = 3 } if i < NUM_ROWS then - current_row.separator = Widget.Line{ + current_row.separator = _G_Widget_.Line{ p1 = { x = side_rows_x, y = current_row_y + _SECTION_HEIGHT_ - 18 @@ -99,7 +97,7 @@ local create_side_rows = function(side_rows_x, side_rows_y, side_rows_tbl) x = side_rows_x + _G_INIT_DATA_.SECTION_WIDTH, y = current_row_y + _SECTION_HEIGHT_ - 18 }, - line_pattern = Patterns.MID_GREY + line_pattern = _G_Patterns_.MID_GREY } end end @@ -107,7 +105,7 @@ end -- LEFT local left = { - header = Widget.Header{ + header = _G_Widget_.Header{ x = _G_INIT_DATA_.LEFT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -121,24 +119,24 @@ create_side_rows(_G_INIT_DATA_.LEFT_X, left.header.bottom_y, left.hours) -- CENTER local center = {} -center.header = Widget.Header{ +center.header = _G_Widget_.Header{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.CENTER_WIDTH, header = 'CURRENT CONDITIONS' } -center.current_desc = Widget.Text{ +center.current_desc = _G_Widget_.Text{ x = _G_INIT_DATA_.CENTER_LEFT_X, y = center.header.bottom_y + 8, - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, font_size = 24 } local _CENTER_X_1_ = _G_INIT_DATA_.CENTER_LEFT_X + _G_INIT_DATA_.SECTION_WIDTH * 0.25 local _CENTER_ICON_WIDTH_ = 120 -center.icon = Widget.ScaledImage{ +center.icon = _G_Widget_.ScaledImage{ x = _CENTER_X_1_ - _CENTER_ICON_WIDTH_ / 2, y = center.header.bottom_y + 105 - _CENTER_ICON_WIDTH_ / 2, width = _CENTER_ICON_WIDTH_, @@ -148,22 +146,22 @@ center.icon = Widget.ScaledImage{ local _CENTER_X_2_ = _G_INIT_DATA_.CENTER_LEFT_X + _G_INIT_DATA_.SECTION_WIDTH * 0.70 local _INFO_Y_ = center.header.bottom_y + 70 -center.current_temp = Widget.Text{ +center.current_temp = _G_Widget_.Text{ x = _CENTER_X_2_, y = _INFO_Y_, x_align = 'center', font_size = 48, - text_color = Patterns.BLUE + text_color = _G_Patterns_.BLUE } -center.obs_time = Widget.Text{ +center.obs_time = _G_Widget_.Text{ x = _CENTER_X_2_, y = _INFO_Y_ + 42, x_align = 'center', font_size = 12, } -center.place = Widget.Text{ +center.place = _G_Widget_.Text{ x = _CENTER_X_2_, y = _INFO_Y_ + 66, x_align = 'center', @@ -173,7 +171,7 @@ center.place = Widget.Text{ local _COLUMN_PADDING_ = 15 local _CENTER_SPACING_ = _SPACING_ + 7 -center.label_column_1 = Widget.TextColumn{ +center.label_column_1 = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.CENTER_RIGHT_X, y = center.header.bottom_y, spacing = _CENTER_SPACING_, @@ -187,17 +185,17 @@ center.label_column_1 = Widget.TextColumn{ 'Precipitation' } -center.info_column_1 = Widget.TextColumn{ +center.info_column_1 = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.CENTER_RIGHT_X + (_G_INIT_DATA_.SECTION_WIDTH - _COLUMN_PADDING_) / 2, y = center.header.bottom_y, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, spacing = _CENTER_SPACING_, font_size = 14, num_rows = 7 } -center.label_column_2 = Widget.TextColumn{ +center.label_column_2 = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.CENTER_RIGHT_X + (_G_INIT_DATA_.SECTION_WIDTH + _COLUMN_PADDING_) / 2, y = center.header.bottom_y, spacing = _CENTER_SPACING_, @@ -211,11 +209,11 @@ center.label_column_2 = Widget.TextColumn{ 'Light Rate' } -center.info_column_2 = Widget.TextColumn{ +center.info_column_2 = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.CENTER_RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH, y = center.header.bottom_y, x_align = 'right', - text_color = Patterns.BLUE, + text_color = _G_Patterns_.BLUE, spacing = _CENTER_SPACING_, font_size = 14, num_rows = 7 @@ -223,7 +221,7 @@ center.info_column_2 = Widget.TextColumn{ -- RIGHT local right = { - header = Widget.Header{ + header = _G_Widget_.Header{ x = _G_INIT_DATA_.RIGHT_X, y = _G_INIT_DATA_.TOP_Y, width = _G_INIT_DATA_.SECTION_WIDTH, @@ -234,9 +232,6 @@ local right = { create_side_rows(_G_INIT_DATA_.RIGHT_X, right.header.bottom_y, right.days) -Widget = nil -Patterns = nil - _SPACING_ = nil _HEADER_PAD_ = nil _ICON_SIDE_LENGTH_ = nil diff --git a/main.lua b/main.lua index e3e915a..9b02c6c 100644 --- a/main.lua +++ b/main.lua @@ -100,6 +100,9 @@ conky_set_update_interval(_G_INIT_DATA_.UPDATE_INTERVAL) require 'imlib2' require 'cairo' +_G_Widget_ = require 'Widget' +_G_Patterns_ = require 'Patterns' + local Util = require 'Util' local Panel = require 'Panel' local System = require 'System' @@ -113,12 +116,10 @@ local Graphics = require 'Graphics' local Memory = require 'Memory' local Weather = require 'Weather' -local updates = -2 +local _unrequire = function(m) package.loaded[m] = nil end -local _unrequire = function(m) - package.loaded[m] = nil - _G[m] = nil -end +_G_Widget_ = nil +_G_Patterns_ = nil _unrequire('Super') _unrequire('Color') @@ -130,6 +131,8 @@ _unrequire = nil _G_INIT_DATA_ = nil +local updates = -2 + local __cairo_xlib_surface_create = cairo_xlib_surface_create local __cairo_create = cairo_create local __cairo_surface_destroy = cairo_surface_destroy