From 41cc2c0e27e6a0860d21754ed9d13f6cd61254ac Mon Sep 17 00:00:00 2001 From: Arvydas Sidorenko Date: Fri, 15 Jun 2012 18:07:05 +0200 Subject: [PATCH] Ported vicious.widgets module to lua 5.2 Signed-off-by: Arvydas Sidorenko Signed-off-by: Adrian C. (anrxc) --- widgets/bat.lua | 5 ++-- widgets/cpu.lua | 5 ++-- widgets/cpufreq.lua | 15 ++++++----- widgets/cpuinf.lua | 5 ++-- widgets/date.lua | 5 ++-- widgets/dio.lua | 5 ++-- widgets/fs.lua | 5 ++-- widgets/gmail.lua | 5 ++-- widgets/hddtemp.lua | 5 ++-- widgets/init.lua | 5 ++-- widgets/mbox.lua | 9 ++++--- widgets/mboxc.lua | 5 ++-- widgets/mdir.lua | 5 ++-- widgets/mem.lua | 37 +++++++++++++------------- widgets/mpd.lua | 5 ++-- widgets/net.lua | 5 ++-- widgets/org.lua | 5 ++-- widgets/os.lua | 5 ++-- widgets/pkg.lua | 11 ++++---- widgets/raid.lua | 5 ++-- widgets/thermal.lua | 9 ++++--- widgets/uptime.lua | 5 ++-- widgets/volume.lua | 5 ++-- widgets/weather.lua | 63 +++++++++++++++++++++++---------------------- widgets/wifi.lua | 5 ++-- 25 files changed, 132 insertions(+), 107 deletions(-) diff --git a/widgets/bat.lua b/widgets/bat.lua index 25a3aac..b0c76d6 100644 --- a/widgets/bat.lua +++ b/widgets/bat.lua @@ -16,7 +16,8 @@ local math = { -- Bat: provides state, charge, and remaining time for a requested battery -module("vicious.widgets.bat") +-- vicious.widgets.bat +local bat = {} -- {{{ Battery widget type @@ -86,4 +87,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mt, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/cpu.lua b/widgets/cpu.lua index 86a3e85..b036b1e 100644 --- a/widgets/cpu.lua +++ b/widgets/cpu.lua @@ -19,7 +19,8 @@ local string = { -- Cpu: provides CPU usage for all available CPUs/cores -module("vicious.widgets.cpu") +-- vicious.widgets.cpu +local cpu = {} -- Initialize function tables @@ -74,4 +75,4 @@ local function worker(format) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpu, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/cpufreq.lua b/widgets/cpufreq.lua index ba9749f..39470a4 100644 --- a/widgets/cpufreq.lua +++ b/widgets/cpufreq.lua @@ -12,14 +12,15 @@ local helpers = require("vicious.helpers") -- Cpufreq: provides freq, voltage and governor info for a requested CPU -module("vicious.widgets.cpufreq") +-- vicious.widgets.cpufreq +local cpufreq = {} -- {{{ CPU frequency widget type local function worker(format, warg) if not warg then return end - local cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq") + local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq") local governor_state = { ["ondemand\n"] = "↯", ["powersave\n"] = "⌁", @@ -34,22 +35,22 @@ local function worker(format, warg) } -- Get the current frequency - local freq = tonumber(cpufreq.scaling_cur_freq) + local freq = tonumber(_cpufreq.scaling_cur_freq) -- Calculate MHz and GHz if freq then freqv.mhz = freq / 1000 freqv.ghz = freqv.mhz / 1000 -- Get the current voltage - if cpufreq.scaling_voltages then - freqv.mv = tonumber(string.match(cpufreq.scaling_voltages, freq.."[%s]([%d]+)")) + if _cpufreq.scaling_voltages then + freqv.mv = tonumber(string.match(_cpufreq.scaling_voltages, freq.."[%s]([%d]+)")) -- Calculate voltage from mV freqv.v = freqv.mv / 1000 end end -- Get the current governor - local governor = cpufreq.scaling_governor + local governor = _cpufreq.scaling_governor -- Represent the governor as a symbol governor = governor_state[governor] or governor or "N/A" @@ -57,4 +58,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpufreq, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/cpuinf.lua b/widgets/cpuinf.lua index b925b27..b0ea782 100644 --- a/widgets/cpuinf.lua +++ b/widgets/cpuinf.lua @@ -12,7 +12,8 @@ local string = { gmatch = string.gmatch } -- Cpuinf: provides speed and cache information for all available CPUs/cores -module("vicious.widgets.cpuinf") +-- vicious.widgets.cpuinf +local cpuinf = {} -- {{{ CPU Information widget type @@ -40,4 +41,4 @@ local function worker(format) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpuinf, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/date.lua b/widgets/date.lua index d3c6ce9..17f4f3f 100644 --- a/widgets/date.lua +++ b/widgets/date.lua @@ -14,7 +14,8 @@ local os = { -- Date: provides access to os.date with optional time formatting -module("vicious.widgets.date") +-- vicious.widgets.date +local date = {} -- {{{ Date widget type @@ -23,4 +24,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(date, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/dio.lua b/widgets/dio.lua index 145ae41..6d13c54 100644 --- a/widgets/dio.lua +++ b/widgets/dio.lua @@ -17,7 +17,8 @@ local os = { -- Disk I/O: provides I/O statistics for requested storage devices -module("vicious.widgets.dio") +-- vicious.widgets.dio +local dio = {} -- Initialize function tables @@ -69,4 +70,4 @@ local function worker(format) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(dio, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/fs.lua b/widgets/fs.lua index 63d2089..c0b7f16 100644 --- a/widgets/fs.lua +++ b/widgets/fs.lua @@ -14,7 +14,8 @@ local helpers = require("vicious.helpers") -- FS: provides file system disk space usage -module("vicious.widgets.fs") +-- vicious.widgets.fs +local fs = {} -- Variable definitions @@ -48,4 +49,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(fs, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/gmail.lua b/widgets/gmail.lua index fe0be45..ba8e731 100644 --- a/widgets/gmail.lua +++ b/widgets/gmail.lua @@ -17,7 +17,8 @@ local string = { -- Gmail: provides count of new and subject of last e-mail on Gmail -module("vicious.widgets.gmail") +-- vicious.widgets.gmail +local gmail = {} -- {{{ Variable definitions @@ -79,4 +80,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(gmail, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/hddtemp.lua b/widgets/hddtemp.lua index 0c79656..85ee767 100644 --- a/widgets/hddtemp.lua +++ b/widgets/hddtemp.lua @@ -12,7 +12,8 @@ local string = { gmatch = string.gmatch } -- Hddtemp: provides hard drive temperatures using the hddtemp daemon -module("vicious.widgets.hddtemp") +-- vicious.widgets.hddtemp +local hddtemp = {} -- {{{ HDD Temperature widget type @@ -34,4 +35,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(hddtemp, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/init.lua b/widgets/init.lua index 6ec6360..4625df0 100644 --- a/widgets/init.lua +++ b/widgets/init.lua @@ -10,8 +10,9 @@ local setmetatable = setmetatable local wrequire = require("vicious.helpers").wrequire -- Vicious: widgets for the awesome window manager -module("vicious.widgets") +-- vicious.widgets +local widgets = { _NAME = "vicious.widgets" } -- }}} -- Load modules at runtime as needed -setmetatable(_M, { __index = wrequire }) +return setmetatable(widgets, { __index = wrequire }) diff --git a/widgets/mbox.lua b/widgets/mbox.lua index be64e03..7b92e36 100644 --- a/widgets/mbox.lua +++ b/widgets/mbox.lua @@ -13,7 +13,8 @@ local helpers = require("vicious.helpers") -- Mbox: provides the subject of last e-mail in a mbox file -module("vicious.widgets.mbox") +-- vicious.widgets.mbox +local mbox = {} -- Initialize variables @@ -24,9 +25,9 @@ local function worker(format, warg) if not warg then return end -- mbox could be huge, get a 30kb chunk from EOF - if type(warg) ~= "table" then mbox = warg end + if type(warg) ~= "table" then _mbox = warg end -- * attachment could be much bigger than 30kb - local f = io.open(mbox or warg[1]) + local f = io.open(_mbox or warg[1]) f:seek("end", -30720) local txt = f:read("*all") f:close() @@ -49,4 +50,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mbox, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/mboxc.lua b/widgets/mboxc.lua index c928cd3..3226917 100644 --- a/widgets/mboxc.lua +++ b/widgets/mboxc.lua @@ -11,7 +11,8 @@ local string = { find = string.find } -- Mboxc: provides the count of total, old and new messages in mbox files -module("vicious.widgets.mboxc") +-- vicious.widgets.mboxc +local mboxc = {} -- {{{ Mbox count widget type @@ -54,4 +55,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mbox, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/mdir.lua b/widgets/mdir.lua index 464d9a1..32dd3b3 100644 --- a/widgets/mdir.lua +++ b/widgets/mdir.lua @@ -11,7 +11,8 @@ local setmetatable = setmetatable -- Mdir: provides the number of new and unread messages in Maildir structures/dirs -module("vicious.widgets.mdir") +-- vicious.widgets.mdir +local mdir = {} -- {{{ Maildir widget type @@ -37,4 +38,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mdir, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/mem.lua b/widgets/mem.lua index dfa06e1..d122654 100644 --- a/widgets/mem.lua +++ b/widgets/mem.lua @@ -13,39 +13,40 @@ local string = { gmatch = string.gmatch } -- Mem: provides RAM and Swap usage statistics -module("vicious.widgets.mem") +-- vicious.widgets.mem +local mem = {} -- {{{ Memory widget type local function worker(format) - local mem = { buf = {}, swp = {} } + local _mem = { buf = {}, swp = {} } -- Get MEM info for line in io.lines("/proc/meminfo") do for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+") do - if k == "MemTotal" then mem.total = math.floor(v/1024) - elseif k == "MemFree" then mem.buf.f = math.floor(v/1024) - elseif k == "Buffers" then mem.buf.b = math.floor(v/1024) - elseif k == "Cached" then mem.buf.c = math.floor(v/1024) - elseif k == "SwapTotal" then mem.swp.t = math.floor(v/1024) - elseif k == "SwapFree" then mem.swp.f = math.floor(v/1024) + if k == "MemTotal" then _mem.total = math.floor(v/1024) + elseif k == "MemFree" then _mem.buf.f = math.floor(v/1024) + elseif k == "Buffers" then _mem.buf.b = math.floor(v/1024) + elseif k == "Cached" then _mem.buf.c = math.floor(v/1024) + elseif k == "SwapTotal" then _mem.swp.t = math.floor(v/1024) + elseif k == "SwapFree" then _mem.swp.f = math.floor(v/1024) end end end -- Calculate memory percentage - mem.free = mem.buf.f + mem.buf.b + mem.buf.c - mem.inuse = mem.total - mem.free - mem.bcuse = mem.total - mem.buf.f - mem.usep = math.floor(mem.inuse / mem.total * 100) + _mem.free = _mem.buf.f + _mem.buf.b + _mem.buf.c + _mem.inuse = _mem.total - _mem.free + _mem.bcuse = _mem.total - _mem.buf.f + _mem.usep = math.floor(_mem.inuse / _mem.total * 100) -- Calculate swap percentage - mem.swp.inuse = mem.swp.t - mem.swp.f - mem.swp.usep = math.floor(mem.swp.inuse / mem.swp.t * 100) + _mem.swp.inuse = _mem.swp.t - _mem.swp.f + _mem.swp.usep = math.floor(_mem.swp.inuse / _mem.swp.t * 100) - return {mem.usep, mem.inuse, mem.total, mem.free, - mem.swp.usep, mem.swp.inuse, mem.swp.t, mem.swp.f, - mem.bcuse } + return {_mem.usep, _mem.inuse, _mem.total, _mem.free, + _mem.swp.usep, _mem.swp.inuse, _mem.swp.t, _mem.swp.f, + _mem.bcuse } end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mem, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/mpd.lua b/widgets/mpd.lua index 143eec9..e4bcb0b 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd.lua @@ -13,7 +13,8 @@ local helpers = require("vicious.helpers") -- Mpd: provides Music Player Daemon information -module("vicious.widgets.mpd") +-- vicious.widgets.mpd +local mpd = {} -- {{{ MPD widget type @@ -60,4 +61,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mpd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/net.lua b/widgets/net.lua index b8a270c..d81d012 100644 --- a/widgets/net.lua +++ b/widgets/net.lua @@ -15,7 +15,8 @@ local helpers = require("vicious.helpers") -- Net: provides state and usage statistics of all network interfaces -module("vicious.widgets.net") +-- vicious.widgets.net +local net = {} -- Initialize function tables @@ -76,4 +77,4 @@ local function worker(format) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(net, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/org.lua b/widgets/org.lua index 2d563b2..5254ab7 100644 --- a/widgets/org.lua +++ b/widgets/org.lua @@ -16,7 +16,8 @@ local os = { -- Org: provides agenda statistics for Emacs org-mode -module("vicious.widgets.org") +-- vicious.widgets.org +local org = {} -- {{{ OrgMode widget type @@ -58,4 +59,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(org, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/os.lua b/widgets/os.lua index 57b807a..288fcd4 100644 --- a/widgets/os.lua +++ b/widgets/os.lua @@ -19,7 +19,8 @@ local string = { -- OS: provides operating system information -module("vicious.widgets.os") +-- vicious.widgets.os +local os = {} -- {{{ Operating system widget type @@ -69,4 +70,4 @@ local function worker(format) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(os, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/pkg.lua b/widgets/pkg.lua index 62d0ccb..9ec03c0 100644 --- a/widgets/pkg.lua +++ b/widgets/pkg.lua @@ -11,7 +11,8 @@ local setmetatable = setmetatable -- Pkg: provides number of pending updates on UNIX systems -module("vicious.widgets.pkg") +-- vicious.widgets.pkg +local pkg = {} -- {{{ Packages widget type @@ -31,16 +32,16 @@ local function worker(format, warg) } -- Check if updates are available - local pkg = manager[warg] - local f = io.popen(pkg.cmd) + local _pkg = manager[warg] + local f = io.popen(_pkg.cmd) for line in f:lines() do updates = updates + 1 end f:close() - return {pkg.sub and math.max(updates-pkg.sub, 0) or updates} + return {_pkg.sub and math.max(updates-_pkg.sub, 0) or updates} end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(pkg, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/raid.lua b/widgets/raid.lua index c1b7e02..e236d11 100644 --- a/widgets/raid.lua +++ b/widgets/raid.lua @@ -16,7 +16,8 @@ local string = { -- Raid: provides state information for a requested RAID array -module("vicious.widgets.raid") +-- vicious.widgets.raid +local raid = {} -- Initialize function tables @@ -54,4 +55,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(raid, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/thermal.lua b/widgets/thermal.lua index c81431f..7592b72 100644 --- a/widgets/thermal.lua +++ b/widgets/thermal.lua @@ -13,7 +13,8 @@ local helpers = require("vicious.helpers") -- Thermal: provides temperature levels of ACPI and coretemp thermal zones -module("vicious.widgets.thermal") +-- vicious.widgets.thermal +local thermal = {} -- {{{ Thermal widget type @@ -28,9 +29,9 @@ local function worker(format, warg) warg = type(warg) == "table" and warg or { warg, "sys" } -- Get temperature from thermal zone - local thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1]) + local _thermal = helpers.pathtotable(zone[warg[2]][1] .. warg[1]) - local data = warg[3] and thermal[warg[3]] or thermal[zone[warg[2]].file] + local data = warg[3] and _thermal[warg[3]] or _thermal[zone[warg[2]].file] if data then if zone[warg[2]].div then return {data / zone[warg[2]].div} @@ -43,4 +44,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(thermal, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/uptime.lua b/widgets/uptime.lua index ece3739..14de99a 100644 --- a/widgets/uptime.lua +++ b/widgets/uptime.lua @@ -13,7 +13,8 @@ local helpers = require("vicious.helpers") -- Uptime: provides system uptime and load information -module("vicious.widgets.uptime") +-- vicious.widgets.uptime +local uptime = {} -- {{{ Uptime widget type @@ -32,4 +33,4 @@ local function worker(format) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +local setmetatable(uptime, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/volume.lua b/widgets/volume.lua index 8f34609..3baa7e6 100644 --- a/widgets/volume.lua +++ b/widgets/volume.lua @@ -12,7 +12,8 @@ local string = { match = string.match } -- Volume: provides volume levels and state of requested ALSA mixers -module("vicious.widgets.volume") +-- vicious.widgets.volume +local volume = {} -- {{{ Volume widget type @@ -49,4 +50,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(volume, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/weather.lua b/widgets/weather.lua index f54fbc3..356f32f 100644 --- a/widgets/weather.lua +++ b/widgets/weather.lua @@ -14,11 +14,12 @@ local helpers = require("vicious.helpers") -- Weather: provides weather information for a requested station -module("vicious.widgets.weather") +-- vicious.widgets.weather +local weather = {} -- Initialize function tables -local weather = { +local _weather = { ["{city}"] = "N/A", ["{wind}"] = "N/A", ["{windmph}"] = "N/A", @@ -43,43 +44,43 @@ local function worker(format, warg) f:close() -- Check if there was a timeout or a problem with the station - if ws == nil then return weather end + if ws == nil then return _weather end - weather["{city}"] = -- City and/or area - string.match(ws, "^(.+)%,.*%([%u]+%)") or weather["{city}"] - weather["{wind}"] = -- Wind direction and degrees if available - string.match(ws, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or weather["{wind}"] - weather["{windmph}"] = -- Wind speed in MPH if available - string.match(ws, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or weather["{windmph}"] - weather["{sky}"] = -- Sky conditions if available - string.match(ws, "Sky[%s]conditions:[%s](.-)[%c]") or weather["{sky}"] - weather["{weather}"] = -- Weather conditions if available - string.match(ws, "Weather:[%s](.-)[%c]") or weather["{weather}"] - weather["{tempf}"] = -- Temperature in fahrenheit - string.match(ws, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or weather["{tempf}"] - weather["{humid}"] = -- Relative humidity in percent - string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or weather["{humid}"] - weather["{press}"] = -- Pressure in hPa - string.match(ws, "Pressure[%s].+%((.+)[%s]hPa%)") or weather["{press}"] + _weather["{city}"] = -- City and/or area + string.match(ws, "^(.+)%,.*%([%u]+%)") or _weather["{city}"] + _weather["{wind}"] = -- Wind direction and degrees if available + string.match(ws, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or _weather["{wind}"] + _weather["{windmph}"] = -- Wind speed in MPH if available + string.match(ws, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or _weather["{windmph}"] + _weather["{sky}"] = -- Sky conditions if available + string.match(ws, "Sky[%s]conditions:[%s](.-)[%c]") or _weather["{sky}"] + _weather["{weather}"] = -- Weather conditions if available + string.match(ws, "Weather:[%s](.-)[%c]") or _weather["{weather}"] + _weather["{tempf}"] = -- Temperature in fahrenheit + string.match(ws, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"] + _weather["{humid}"] = -- Relative humidity in percent + string.match(ws, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"] + _weather["{press}"] = -- Pressure in hPa + string.match(ws, "Pressure[%s].+%((.+)[%s]hPa%)") or _weather["{press}"] -- Wind speed in km/h if MPH was available - if weather["{windmph}"] ~= "N/A" then - weather["{windmph}"] = tonumber(weather["{windmph}"]) - weather["{windkmh}"] = math.ceil(weather["{windmph}"] * 1.6) + if _weather["{windmph}"] ~= "N/A" then + _weather["{windmph}"] = tonumber(_weather["{windmph}"]) + _weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6) end -- Temperature in °C if °F was available - if weather["{tempf}"] ~= "N/A" then - weather["{tempf}"] = tonumber(weather["{tempf}"]) - weather["{tempc}"] = math.ceil((weather["{tempf}"] - 32) * 5/9) + if _weather["{tempf}"] ~= "N/A" then + _weather["{tempf}"] = tonumber(_weather["{tempf}"]) + _weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9) end -- Capitalize some stats so they don't look so out of place - if weather["{sky}"] ~= "N/A" then - weather["{sky}"] = helpers.capitalize(weather["{sky}"]) + if _weather["{sky}"] ~= "N/A" then + _weather["{sky}"] = helpers.capitalize(_weather["{sky}"]) end - if weather["{weather}"] ~= "N/A" then - weather["{weather}"] = helpers.capitalize(weather["{weather}"]) + if _weather["{weather}"] ~= "N/A" then + _weather["{weather}"] = helpers.capitalize(_weather["{weather}"]) end - return weather + return _weather end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(weather, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/wifi.lua b/widgets/wifi.lua index 3e30dc9..80dcdee 100644 --- a/widgets/wifi.lua +++ b/widgets/wifi.lua @@ -20,7 +20,8 @@ local string = { -- Wifi: provides wireless information for a requested interface -module("vicious.widgets.wifi") +-- vicious.widgets.wifi +local wifi = {} -- {{{ Wireless widget type @@ -77,4 +78,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(wifi, { __call = function(_, ...) return worker(...) end })