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