added wifi and wifiiw widget
This commit is contained in:
parent
0a3af4168d
commit
568692b38d
28
README.md
28
README.md
|
@ -454,7 +454,7 @@ Provides weather information for a requested station.
|
|||
Supported platforms: platform independent (required tools: `curl`).
|
||||
|
||||
- Arguments:
|
||||
* Takes the ICAO station code as an argument, i.e. "LDRI"
|
||||
* Takes the ICAO station code as an argument, i.e. `"LDRI"`
|
||||
- Returns:
|
||||
* Returns a table with string keys: `{city}`, `{wind}`, `{windmph}`,
|
||||
`{windkmh}`, `{sky}`, `{weather}`, `{tempf}`, `{tempc}`, `{humid}`,
|
||||
|
@ -462,19 +462,27 @@ Supported platforms: platform independent (required tools: `curl`).
|
|||
|
||||
**vicious.widgets.wifi**
|
||||
|
||||
- provides wireless information for a requested interface
|
||||
- takes the network interface as an argument, i.e. "wlan0"
|
||||
- returns a table with string keys: {ssid}, {mode}, {chan}, {rate},
|
||||
{link}, {linp} (link quality in percent) and {sign} (signal level)
|
||||
Provides wireless information for a requested interface.
|
||||
Supported platforms: Linux.
|
||||
|
||||
- Arguments:
|
||||
* Takes the network interface as an argument, i.e. "wlan0"
|
||||
- Returns:
|
||||
* Returns a table with string keys: `{ssid}`, `{mode}`, `{chan}`, `{rate}`,
|
||||
`{link}`, `{linp}` (link quality in percent) and `{sign}` (signal level)
|
||||
|
||||
**vicious.widgets.wifiiw**
|
||||
|
||||
- similar to vicious.widgets.wifi, but uses iw instead of iwconfig
|
||||
- provides wireless information for a requested interface
|
||||
- takes the network interface as an argument, i.e. "wlan0"
|
||||
- returns a table with string keys: {ssid}, {mode}, {chan}, {rate},
|
||||
{freq}, {linp} (link quality in percent), {txpw} (tx power) and {sign} (signal level)
|
||||
Provides wireless information for a requested interface (similar to
|
||||
vicious.widgets.wifi, but uses iw instead of iwconfig).
|
||||
Supported platforms: Linux.
|
||||
|
||||
- Arguments:
|
||||
* Takes the network interface as an argument, i.e. "wlan0"
|
||||
- Returns:
|
||||
* Returns a table with string keys: `{ssid}`, `{mode}`, `{chan}`, `{rate}`,
|
||||
`{freq}`, `{linp}` (link quality in percent), `{txpw}` (tx power) and
|
||||
`{sign}` (signal level)
|
||||
|
||||
|
||||
Custom widget types
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
---------------------------------------------------
|
||||
-- Licensed under the GNU General Public License v2
|
||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
||||
---------------------------------------------------
|
||||
|
||||
-- {{{ Grab environment
|
||||
local io = { lines = io.lines }
|
||||
local setmetatable = setmetatable
|
||||
local math = { floor = math.floor }
|
||||
local string = { gmatch = string.gmatch }
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Mem: provides RAM and Swap usage statistics
|
||||
-- vicious.widgets.mem
|
||||
local mem = {}
|
||||
|
||||
|
||||
-- {{{ Memory widget type
|
||||
local function worker(format)
|
||||
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)
|
||||
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)
|
||||
-- Calculate swap percentage
|
||||
_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 }
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
|
|
@ -21,7 +21,7 @@ local string = {
|
|||
|
||||
-- Wifi: provides wireless information for a requested interface
|
||||
-- vicious.widgets.wifi
|
||||
local wifi = {}
|
||||
local wifi_linux = {}
|
||||
|
||||
|
||||
-- {{{ Variable definitions
|
||||
|
@ -89,4 +89,4 @@ local function worker(format, warg)
|
|||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(wifi, { __call = function(_, ...) return worker(...) end })
|
||||
return setmetatable(wifi_linux, { __call = function(_, ...) return worker(...) end })
|
|
@ -20,7 +20,7 @@ local string = {
|
|||
|
||||
-- Wifiiw: provides wireless information for a requested interface using iw instead of deprecated iwconfig
|
||||
-- vicious.widgets.wifiiw
|
||||
local wifiiw = {}
|
||||
local wifiiw_linux = {}
|
||||
|
||||
|
||||
-- {{{ Wireless widget type
|
||||
|
@ -63,4 +63,4 @@ local function worker(format, warg)
|
|||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(wifiiw, { __call = function(_, ...) return worker(...) end })
|
||||
return setmetatable(wifiiw_linux, { __call = function(_, ...) return worker(...) end })
|
Loading…
Reference in New Issue