From 3baade7b06df8cf274dae4963779d584adca788f Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:46:54 +0100 Subject: [PATCH 01/47] helpers.lua: restructure to support multiple operating systems --- helpers.lua | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/helpers.lua b/helpers.lua index 91d9096..0555e95 100644 --- a/helpers.lua +++ b/helpers.lua @@ -12,13 +12,19 @@ local pairs = pairs local rawget = rawget local require = require local tonumber = tonumber -local io = { open = io.open } +local io = { + open = io.open, + popen = io.popen +} local setmetatable = setmetatable local getmetatable = getmetatable local string = { upper = string.upper, + lower = string.lower, format = string.format } +local pcall = pcall +local assert = assert -- }}} @@ -32,11 +38,45 @@ local scroller = {} -- }}} -- {{{ Helper functions +-- {{{ Determine operating system +function helpers.getos() + local f = io.popen("uname -s") + local uname = f:read("*line") + f:close() + + return string.lower(uname) +end +-- }}} + -- {{{ Loader of vicious modules function helpers.wrequire(table, key) - local module = rawget(table, key) - return module or require(table._NAME .. "." .. key) + local ret = rawget(table, key) + + if ret then + return ret + end + + local ostable = { + linux = { "linux", "all" }, + freebsd = { "freebsd", "bsd", "all" } + } + + local os = ostable[helpers.getos()] + assert(os, "Vicious: platform not supported.") + + for i = 1, #os do + local status, value = pcall(require, table._NAME .. "." .. key .. "_" .. os[i]) + if status then + ret = value + break + end + end + + assert(ret, "Vicious: widget " .. table._NAME .. "." .. key .. " not available for current platform.") + + return ret end +-- }}} -- {{{ Expose path as a Lua table function helpers.pathtotable(dir) From 78e1242601d064cc96996a7534a04004e9824d48 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:47:33 +0100 Subject: [PATCH 02/47] helpers: add sysctl helper for freebsd --- helpers.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/helpers.lua b/helpers.lua index 0555e95..3288e64 100644 --- a/helpers.lua +++ b/helpers.lua @@ -196,6 +196,44 @@ function helpers.scroll(text, maxlen, widget) end -- }}} +-- {{{ Return result from one sysctl variable as string +function helpers.sysctl(path) + local fd = io.popen("sysctl -n " .. helpers.shellquote(path)) + + if not fd then + return + end + + local ret = fd:read() + + fd:close() + + return ret +end +-- }}} + +-- {{{ Return result from multiple sysctl variables as table +function helpers.sysctl_table(syspath) + return setmetatable({ _path = syspath }, + { __index = function(table, index) + local path = "sysctl -n " .. helpers.shellquote(table._path .. "." .. index) + local f = io.popen(path) + if f then + local s = f:read("*all") + f:close() + if select(2, s:gsub("\n", "\n")) > 1 then + local o = { _path = path} + setmetatable(o, getmetatable(table)) + return o + else + return s + end + end + end + }) +end +-- }}} + return helpers -- }}} From 5628c9e47864c3bb69199b8caf12aef4b9081f61 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:59:31 +0100 Subject: [PATCH 03/47] port bat widget to freebsd --- widgets/bat_freebsd.lua | 69 ++++++++++++++++++++++++++++++ widgets/{bat.lua => bat_linux.lua} | 4 +- 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 widgets/bat_freebsd.lua rename widgets/{bat.lua => bat_linux.lua} (96%) diff --git a/widgets/bat_freebsd.lua b/widgets/bat_freebsd.lua new file mode 100644 index 0000000..c87dbfa --- /dev/null +++ b/widgets/bat_freebsd.lua @@ -0,0 +1,69 @@ +-- {{{ Grab environment +local setmetatable = setmetatable +local tonumber = tonumber +local io = { popen = io.popen } +local math = { floor = math.floor } +local helpers = require("vicious.helpers") +local string = { + gmatch = string.gmatch, + match = string.match, + format = string.format + +} +-- }}} +local bat_freebsd = {} + +local function worker(format, warg) + local battery = warg or "batt" + local bat_info = {} + local f = io.popen("acpiconf -i " .. helpers.shellquote(battery)) + for line in f:lines("*line") do + for key,value in string.gmatch(line, "(.+):%s+(.+)") do + bat_info[key] = value + end + end + f:close() + + -- current state + local state + if bat_info["State"] == "high" then + state = "↯" + elseif bat_info["State"] == "charging" then + state = "+" + elseif bat_info["State"] == "discharging" then + state = "-" + else + state = "⌁" + end + + -- battery capacity in percent + local percent = tonumber(string.match(bat_info["Remaining capacity"], "[%d]+")) + + -- use remaining (charging or discharging) time calculated by acpiconf + local time = bat_info["Remaining time"] + if time == "unknown" then + time = "∞" + end + + -- calculate wear level from (last full / design) capacity + local wear = "N/A" + if bat_info["Last full capacity"] and bat_info["Design capacity"] then + local l_full = tonumber(string.match(bat_info["Last full capacity"], "[%d]+")) + local design = tonumber(string.match(bat_info["Design capacity"], "[%d]+")) + wear = math.floor(100 - (l_full / design * 100)) + end + + -- dis-/charging rate as presented by battery + local rate = string.match(bat_info["Present rate"], "([%d]+)%smW") + rate = string.format("%2.1f", tonumber(rate / 1000)) + + -- returns + -- * state (high "↯", discharging "-", charging "+", N/A "⌁" } + -- * remaining_capacity (percent) + -- * remaining_time, by battery + -- * wear level (percent) + -- * present_rate (mW) + return {state, percent, time, wear, rate} +end + +return setmetatable(bat_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/bat.lua b/widgets/bat_linux.lua similarity index 96% rename from widgets/bat.lua rename to widgets/bat_linux.lua index 1f491d9..66f5b17 100644 --- a/widgets/bat.lua +++ b/widgets/bat_linux.lua @@ -18,7 +18,7 @@ local math = { -- Bat: provides state, charge, remaining time, and wear for a requested battery -- vicious.widgets.bat -local bat = {} +local bat_linux = {} -- {{{ Battery widget type @@ -91,4 +91,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(bat, { __call = function(_, ...) return worker(...) end }) +return setmetatable(bat_linux, { __call = function(_, ...) return worker(...) end }) From d7c99133e1926fa118ae2fd3e7e0b81abf15c610 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:59:52 +0100 Subject: [PATCH 04/47] port cpu widget to freebsd --- widgets/cpu_freebsd.lua | 69 ++++++++++++++++++++++++++++++ widgets/{cpu.lua => cpu_linux.lua} | 4 +- 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 widgets/cpu_freebsd.lua rename widgets/{cpu.lua => cpu_linux.lua} (94%) diff --git a/widgets/cpu_freebsd.lua b/widgets/cpu_freebsd.lua new file mode 100644 index 0000000..044286c --- /dev/null +++ b/widgets/cpu_freebsd.lua @@ -0,0 +1,69 @@ +-- {{{ Grab environment +local helpers = require("vicious.helpers") +local tonumber = tonumber +local setmetatable = setmetatable +local math = { floor = math.floor } +local string = { gmatch = string.gmatch } +-- }}} + + +-- Cpu: provides CPU usage for all available CPUs/cores +-- vicious.widgets.cpu_freebsd +local cpu_freebsd = {} + +-- Initialize function tables +local cpu_total = {} +local cpu_idle = {} + +-- {{{ CPU widget type +local function worker(format) + local cp_times = helpers.sysctl("kern.cp_times") + local matches = {} + local tmp_total = {} + local tmp_idle = {} + local tmp_usage = {} + + -- Read input data + for v in string.gmatch(cp_times, "([%d]+)") do + table.insert(matches, v) + end + + -- Set first value of function tables + if #cpu_total == 0 then -- check for empty table + for i = 1, #matches / 5 + 1 do + cpu_total[i] = 0 + cpu_idle[i] = 0 + end + end + for i = 1, #matches / 5 + 1 do + tmp_total[i] = 0 + tmp_idle[i] = 0 + tmp_usage[i] = 0 + end + + -- CPU usage + for i, v in ipairs(matches) do + local index = math.floor((i-1) / 5) + 2 -- current cpu + + tmp_total[1] = tmp_total[1] + v + tmp_total[index] = tmp_total[index] + v + + if (i-1) % 5 == 4 then + tmp_idle[1] = tmp_idle[1] + v + tmp_idle[index] = tmp_idle[index] + v + end + end + + for i = 1, #tmp_usage do + tmp_usage[i] = tmp_total[i] - cpu_total[i] + tmp_usage[i] = math.floor((tmp_usage[i] - (tmp_idle[i] - cpu_idle[i])) / tmp_usage[i] * 100) + end + + cpu_total = tmp_total + cpu_idle = tmp_idle + + return tmp_usage +end +-- }}} + +return setmetatable(cpu_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/cpu.lua b/widgets/cpu_linux.lua similarity index 94% rename from widgets/cpu.lua rename to widgets/cpu_linux.lua index fe6754a..99ec1b2 100644 --- a/widgets/cpu.lua +++ b/widgets/cpu_linux.lua @@ -20,7 +20,7 @@ local string = { -- Cpu: provides CPU usage for all available CPUs/cores -- vicious.widgets.cpu -local cpu = {} +local cpu_linux = {} -- Initialize function tables @@ -77,4 +77,4 @@ local function worker(format) end -- }}} -return setmetatable(cpu, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpu_linux, { __call = function(_, ...) return worker(...) end }) From fbd91c9b37f7006b14d62aa7d9403b0028c6560b Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:49:37 +0100 Subject: [PATCH 05/47] port cpufreq widget to freebsd --- widgets/cpufreq_freebsd.lua | 34 ++++++++++++++++++++++ widgets/{cpufreq.lua => cpufreq_linux.lua} | 4 +-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 widgets/cpufreq_freebsd.lua rename widgets/{cpufreq.lua => cpufreq_linux.lua} (93%) diff --git a/widgets/cpufreq_freebsd.lua b/widgets/cpufreq_freebsd.lua new file mode 100644 index 0000000..351cc68 --- /dev/null +++ b/widgets/cpufreq_freebsd.lua @@ -0,0 +1,34 @@ +-- {{{ Grab environment +local tonumber = tonumber +local setmetatable = setmetatable +local helpers = require("vicious.helpers") +-- }}} + + +-- Cpufreq: provides freq, voltage and governor info for a requested CPU +-- vicious.widgets.cpufreq +local cpufreq_freebsd = {} + + +-- {{{ CPU frequency widget type +local function worker(format, warg) + if not warg then return end + + -- Default frequency and voltage values + local freqv = { + ["mhz"] = "N/A", ["ghz"] = "N/A", + ["v"] = "N/A", ["mv"] = "N/A", + } + + local freq = tonumber(helpers.sysctl("dev.cpu." .. warg .. ".freq")) + + freqv.mhz = freq + freqv.ghz = freq / 1000 + + local governor = "N/A" + + return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor} +end +-- }}} + +return setmetatable(cpufreq_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/cpufreq.lua b/widgets/cpufreq_linux.lua similarity index 93% rename from widgets/cpufreq.lua rename to widgets/cpufreq_linux.lua index 39470a4..4cac998 100644 --- a/widgets/cpufreq.lua +++ b/widgets/cpufreq_linux.lua @@ -13,7 +13,7 @@ local helpers = require("vicious.helpers") -- Cpufreq: provides freq, voltage and governor info for a requested CPU -- vicious.widgets.cpufreq -local cpufreq = {} +local cpufreq_linux = {} -- {{{ CPU frequency widget type @@ -58,4 +58,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(cpufreq, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end }) From 968fee1a541679a110fc333d96adf90edfade577 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:49:57 +0100 Subject: [PATCH 06/47] move cpuinf widget to match new layout --- widgets/{cpuinf.lua => cpuinf_linux.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{cpuinf.lua => cpuinf_linux.lua} (91%) diff --git a/widgets/cpuinf.lua b/widgets/cpuinf_linux.lua similarity index 91% rename from widgets/cpuinf.lua rename to widgets/cpuinf_linux.lua index b0ea782..11a7012 100644 --- a/widgets/cpuinf.lua +++ b/widgets/cpuinf_linux.lua @@ -13,7 +13,7 @@ local string = { gmatch = string.gmatch } -- Cpuinf: provides speed and cache information for all available CPUs/cores -- vicious.widgets.cpuinf -local cpuinf = {} +local cpuinf_linux = {} -- {{{ CPU Information widget type @@ -41,4 +41,4 @@ local function worker(format) end -- }}} -return setmetatable(cpuinf, { __call = function(_, ...) return worker(...) end }) +return setmetatable(cpuinf_linux, { __call = function(_, ...) return worker(...) end }) From 62dbf146a0bf4c4d8e606d604e7761e0b3d890ff Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:50:29 +0100 Subject: [PATCH 07/47] move date widget to match new layout --- widgets/{date.lua => date_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{date.lua => date_all.lua} (85%) diff --git a/widgets/date.lua b/widgets/date_all.lua similarity index 85% rename from widgets/date.lua rename to widgets/date_all.lua index 17f4f3f..afcf085 100644 --- a/widgets/date.lua +++ b/widgets/date_all.lua @@ -15,7 +15,7 @@ local os = { -- Date: provides access to os.date with optional time formatting -- vicious.widgets.date -local date = {} +local date_all = {} -- {{{ Date widget type @@ -24,4 +24,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(date, { __call = function(_, ...) return worker(...) end }) +return setmetatable(date_all, { __call = function(_, ...) return worker(...) end }) From ba4b94899e3d9387068be5110a2ff03dd9860d7d Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:50:55 +0100 Subject: [PATCH 08/47] move dio to match new layout --- widgets/{dio.lua => dio_linux.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{dio.lua => dio_linux.lua} (95%) diff --git a/widgets/dio.lua b/widgets/dio_linux.lua similarity index 95% rename from widgets/dio.lua rename to widgets/dio_linux.lua index 6d13c54..b73cd21 100644 --- a/widgets/dio.lua +++ b/widgets/dio_linux.lua @@ -18,7 +18,7 @@ local os = { -- Disk I/O: provides I/O statistics for requested storage devices -- vicious.widgets.dio -local dio = {} +local dio_linux = {} -- Initialize function tables @@ -70,4 +70,4 @@ local function worker(format) end -- }}} -return setmetatable(dio, { __call = function(_, ...) return worker(...) end }) +return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end }) From 108ab2eb8255679d0e192d3a23280c36509d13f1 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:51:16 +0100 Subject: [PATCH 09/47] move fs widget to match new layout --- widgets/{fs.lua => fs_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{fs.lua => fs_all.lua} (94%) diff --git a/widgets/fs.lua b/widgets/fs_all.lua similarity index 94% rename from widgets/fs.lua rename to widgets/fs_all.lua index 4b889dc..eb4d044 100644 --- a/widgets/fs.lua +++ b/widgets/fs_all.lua @@ -15,7 +15,7 @@ local helpers = require("vicious.helpers") -- FS: provides file system disk space usage -- vicious.widgets.fs -local fs = {} +local fs_all = {} -- Variable definitions @@ -49,4 +49,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(fs, { __call = function(_, ...) return worker(...) end }) +return setmetatable(fs_all, { __call = function(_, ...) return worker(...) end }) From 9a727d417e63a62ce72b9fe58be0c2bb18ecda37 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:51:41 +0100 Subject: [PATCH 10/47] move gmail to match new layout --- widgets/{gmail.lua => gmail_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{gmail.lua => gmail_all.lua} (94%) diff --git a/widgets/gmail.lua b/widgets/gmail_all.lua similarity index 94% rename from widgets/gmail.lua rename to widgets/gmail_all.lua index e3e5503..4c1a0c2 100644 --- a/widgets/gmail.lua +++ b/widgets/gmail_all.lua @@ -17,7 +17,7 @@ local string = { -- Gmail: provides count of new and subject of last e-mail on Gmail -- vicious.widgets.gmail -local gmail = {} +local gmail_all = {} -- {{{ Variable definitions @@ -74,4 +74,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(gmail, { __call = function(_, ...) return worker(...) end }) +return setmetatable(gmail_all, { __call = function(_, ...) return worker(...) end }) From bb5e6af08c23f0205c4c2fa8e700c5ee9fcc383a Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:51:57 +0100 Subject: [PATCH 11/47] move hddtemp widget to match new layout --- widgets/{hddtemp.lua => hddtemp_linux.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{hddtemp.lua => hddtemp_linux.lua} (90%) diff --git a/widgets/hddtemp.lua b/widgets/hddtemp_linux.lua similarity index 90% rename from widgets/hddtemp.lua rename to widgets/hddtemp_linux.lua index 5c2b1a6..c46eb13 100644 --- a/widgets/hddtemp.lua +++ b/widgets/hddtemp_linux.lua @@ -14,7 +14,7 @@ local helpers = require("vicious.helpers") -- Hddtemp: provides hard drive temperatures using the hddtemp daemon -- vicious.widgets.hddtemp -local hddtemp = {} +local hddtemp_linux = {} -- {{{ HDD Temperature widget type @@ -37,4 +37,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(hddtemp, { __call = function(_, ...) return worker(...) end }) +return setmetatable(hddtemp_linux, { __call = function(_, ...) return worker(...) end }) From 2605a1b744c84057ad9461f36684bd495e003efa Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:52:40 +0100 Subject: [PATCH 12/47] move mbox widget to match new layout --- widgets/{mbox.lua => mbox_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{mbox.lua => mbox_all.lua} (92%) diff --git a/widgets/mbox.lua b/widgets/mbox_all.lua similarity index 92% rename from widgets/mbox.lua rename to widgets/mbox_all.lua index 7b92e36..31d5638 100644 --- a/widgets/mbox.lua +++ b/widgets/mbox_all.lua @@ -14,7 +14,7 @@ local helpers = require("vicious.helpers") -- Mbox: provides the subject of last e-mail in a mbox file -- vicious.widgets.mbox -local mbox = {} +local mbox_all = {} -- Initialize variables @@ -50,4 +50,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(mbox, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mbox_all, { __call = function(_, ...) return worker(...) end }) From 9695e0fea045ec8b0379fae23e396a050d357151 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:53:03 +0100 Subject: [PATCH 13/47] move mboxc widget to match new layout --- widgets/{mboxc.lua => mboxc_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{mboxc.lua => mboxc_all.lua} (94%) diff --git a/widgets/mboxc.lua b/widgets/mboxc_all.lua similarity index 94% rename from widgets/mboxc.lua rename to widgets/mboxc_all.lua index a79d1f4..8743ebb 100644 --- a/widgets/mboxc.lua +++ b/widgets/mboxc_all.lua @@ -12,7 +12,7 @@ local string = { find = string.find } -- Mboxc: provides the count of total, old and new messages in mbox files -- vicious.widgets.mboxc -local mboxc = {} +local mboxc_all = {} -- {{{ Mbox count widget type @@ -55,4 +55,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(mboxc, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mboxc_all, { __call = function(_, ...) return worker(...) end }) From 261684f8b8fbfa405c3364800a1b74e84d440a26 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:53:14 +0100 Subject: [PATCH 14/47] move mdir widget to match new layout --- widgets/{mdir.lua => mdir_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{mdir.lua => mdir_all.lua} (92%) diff --git a/widgets/mdir.lua b/widgets/mdir_all.lua similarity index 92% rename from widgets/mdir.lua rename to widgets/mdir_all.lua index bea9088..793609e 100644 --- a/widgets/mdir.lua +++ b/widgets/mdir_all.lua @@ -13,7 +13,7 @@ local helpers = require("vicious.helpers") -- Mdir: provides the number of new and unread messages in Maildir structures/dirs -- vicious.widgets.mdir -local mdir = {} +local mdir_all = {} -- {{{ Maildir widget type @@ -40,4 +40,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(mdir, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mdir_all, { __call = function(_, ...) return worker(...) end }) From 70f42e5d5418df6e87606f172f5b501aeebdccb8 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:53:29 +0100 Subject: [PATCH 15/47] port mem widget to freebsd --- widgets/mem_freebsd.lua | 70 ++++++++++++++++++++++++++++++ widgets/{mem.lua => mem_linux.lua} | 4 +- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 widgets/mem_freebsd.lua rename widgets/{mem.lua => mem_linux.lua} (94%) diff --git a/widgets/mem_freebsd.lua b/widgets/mem_freebsd.lua new file mode 100644 index 0000000..618c418 --- /dev/null +++ b/widgets/mem_freebsd.lua @@ -0,0 +1,70 @@ +-- {{{ Grab environment +local tonumber = tonumber +local setmetatable = setmetatable +local math = { floor = math.floor } +local helpers = require("vicious.helpers") +-- }}} + +-- Mem: provides RAM and Swap usage statistics +-- vicious.widgets.mem_freebsd +local mem_freebsd = {} + + +-- {{{ Memory widget type +local function worker(format) + local pagesize = tonumber(helpers.sysctl("hw.pagesize")) + local vm_stats = helpers.sysctl_table("vm.stats.vm") + local _mem = { buf = {}, total = nil } + + _mem.total = tonumber(vm_stats.v_page_count) * pagesize + _mem.buf.f = tonumber(vm_stats.v_free_count) * pagesize + _mem.buf.a = tonumber(vm_stats.v_active_count) * pagesize + _mem.buf.i = tonumber(vm_stats.v_inactive_count) * pagesize + _mem.buf.c = tonumber(vm_stats.v_cache_count) * pagesize + _mem.buf.w = tonumber(vm_stats.v_wire_count) * pagesize + + -- rework into Megabytes + _mem.total = math.floor(_mem.total/(1024*1024)) + _mem.buf.f = math.floor(_mem.buf.f/(1024*1024)) + _mem.buf.a = math.floor(_mem.buf.a/(1024*1024)) + _mem.buf.i = math.floor(_mem.buf.i/(1024*1024)) + _mem.buf.c = math.floor(_mem.buf.c/(1024*1024)) + _mem.buf.w = math.floor(_mem.buf.w/(1024*1024)) + + -- Calculate memory percentage + _mem.free = _mem.buf.f + _mem.buf.c + _mem.inuse = _mem.buf.a + _mem.buf.i + _mem.wire = _mem.buf.w + _mem.bcuse = _mem.total - _mem.buf.f + _mem.usep = math.floor(_mem.inuse / _mem.total * 100) + _mem.inusep= math.floor(_mem.inuse / _mem.total * 100) + _mem.buffp = math.floor(_mem.bcuse / _mem.total * 100) + _mem.wirep = math.floor(_mem.wire / _mem.total * 100) + + -- Get swap states + local vm = helpers.sysctl_table("vm") + local _swp = { buf = {}, total = nil } + + if tonumber(vm.swap_enabled) == 1 and tonumber(vm.swap_total) > 0 then + -- Get swap space + _swp.total = tonumber(vm.swap_total) + _swp.buf.f = _swp.total - tonumber(vm_stats.v_swapin) + -- Rework into megabytes + _swp.total = math.floor(_swp.total/(1024*1024)) + _swp.buf.f = math.floor(_swp.buf.f/(1024*1024)) + -- Calculate percentage + _swp.inuse = _swp.total - _swp.buf.f + _swp.usep = math.floor(_swp.inuse / _swp.total * 100) + else + _swp.usep = -1 + _swp.inuse = -1 + _swp.total = -1 + _swp.buf.f = -1 + end + + return { _mem.usep, _mem.inuse, _mem.total, _mem.free, + _swp.usep, _swp.inuse, _swp.total, _swp.buf.f, + _mem.bcuse, _mem.buffp, _mem.wirep } +end + +return setmetatable(mem_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/mem.lua b/widgets/mem_linux.lua similarity index 94% rename from widgets/mem.lua rename to widgets/mem_linux.lua index 67ef42a..4ff35d8 100644 --- a/widgets/mem.lua +++ b/widgets/mem_linux.lua @@ -14,7 +14,7 @@ local string = { gmatch = string.gmatch } -- Mem: provides RAM and Swap usage statistics -- vicious.widgets.mem -local mem = {} +local mem_linux = {} -- {{{ Memory widget type @@ -49,4 +49,4 @@ local function worker(format) end -- }}} -return setmetatable(mem, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mem_linux, { __call = function(_, ...) return worker(...) end }) From 5b30e432e6b3936fe00c3fbaf019a0e73f0f2eeb Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:53:46 +0100 Subject: [PATCH 16/47] move mpd widget to match new layout --- widgets/{mpd.lua => mpd_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{mpd.lua => mpd_all.lua} (95%) diff --git a/widgets/mpd.lua b/widgets/mpd_all.lua similarity index 95% rename from widgets/mpd.lua rename to widgets/mpd_all.lua index e4bcb0b..31ee850 100644 --- a/widgets/mpd.lua +++ b/widgets/mpd_all.lua @@ -14,7 +14,7 @@ local helpers = require("vicious.helpers") -- Mpd: provides Music Player Daemon information -- vicious.widgets.mpd -local mpd = {} +local mpd_all = {} -- {{{ MPD widget type @@ -61,4 +61,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(mpd, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mpd_all, { __call = function(_, ...) return worker(...) end }) From c8c43d53ee6f4f70be7b220b0d1dafb13476258b Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:54:14 +0100 Subject: [PATCH 17/47] port net widget to freebsd --- widgets/net_freebsd.lua | 83 ++++++++++++++++++++++++++++++ widgets/{net.lua => net_linux.lua} | 4 +- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 widgets/net_freebsd.lua rename widgets/{net.lua => net_linux.lua} (96%) diff --git a/widgets/net_freebsd.lua b/widgets/net_freebsd.lua new file mode 100644 index 0000000..f78b016 --- /dev/null +++ b/widgets/net_freebsd.lua @@ -0,0 +1,83 @@ +-- {{{ Grab environment +local tonumber = tonumber +local os = { time = os.time } +local setmetatable = setmetatable +local helpers = require("vicious.helpers") +local io = { popen = io.popen } +local string = { match = string.match } +-- }}} + + +-- Net: provides state and usage statistics of all network interfaces +-- vicious.widgets.net +local net_freebsd = {} + + +-- Initialize function tables +local nets = {} +-- Variable definitions +local unit = { ["b"] = 1, ["kb"] = 1024, + ["mb"] = 1024^2, ["gb"] = 1024^3 +} + +-- {{{ Net widget type +local function worker(format, warg) + if not warg then return end + + local args = {} + local buffer = nil + local f = io.popen("netstat -n -b -I " .. helpers.shellquote(warg)) + local now = os.time() + + for line in f:lines() do + if not (line:find(" Date: Wed, 25 Jan 2017 17:54:31 +0100 Subject: [PATCH 18/47] move org widget to match new layout --- widgets/{org.lua => org_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{org.lua => org_all.lua} (94%) diff --git a/widgets/org.lua b/widgets/org_all.lua similarity index 94% rename from widgets/org.lua rename to widgets/org_all.lua index 5254ab7..2fdbf23 100644 --- a/widgets/org.lua +++ b/widgets/org_all.lua @@ -17,7 +17,7 @@ local os = { -- Org: provides agenda statistics for Emacs org-mode -- vicious.widgets.org -local org = {} +local org_all = {} -- {{{ OrgMode widget type @@ -59,4 +59,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(org, { __call = function(_, ...) return worker(...) end }) +return setmetatable(org_all, { __call = function(_, ...) return worker(...) end }) From cdaa62884d353e19e6b7d946b5de2055707a6ffe Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:54:44 +0100 Subject: [PATCH 19/47] move os widget to match new layout --- widgets/{os.lua => os_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{os.lua => os_all.lua} (95%) diff --git a/widgets/os.lua b/widgets/os_all.lua similarity index 95% rename from widgets/os.lua rename to widgets/os_all.lua index 52180e3..4c41338 100644 --- a/widgets/os.lua +++ b/widgets/os_all.lua @@ -20,7 +20,7 @@ local string = { -- OS: provides operating system information -- vicious.widgets.os -local os = {} +local os_all = {} -- {{{ Operating system widget type @@ -70,4 +70,4 @@ local function worker(format) end -- }}} -return setmetatable(os, { __call = function(_, ...) return worker(...) end }) +return setmetatable(os_all, { __call = function(_, ...) return worker(...) end }) From 909db88b009710527d371749f1f9aa601b21966c Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:54:55 +0100 Subject: [PATCH 20/47] move pkg widget to match new layout --- widgets/{pkg.lua => pkg_all.lua} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename widgets/{pkg.lua => pkg_all.lua} (88%) diff --git a/widgets/pkg.lua b/widgets/pkg_all.lua similarity index 88% rename from widgets/pkg.lua rename to widgets/pkg_all.lua index f552b9f..3899554 100644 --- a/widgets/pkg.lua +++ b/widgets/pkg_all.lua @@ -12,7 +12,7 @@ local setmetatable = setmetatable -- Pkg: provides number of pending updates on UNIX systems -- vicious.widgets.pkg -local pkg = {} +local pkg_all = {} -- {{{ Packages widget type @@ -28,7 +28,7 @@ local function worker(format, warg) ["Debian"] = { cmd = "apt-show-versions -u -b" }, ["Ubuntu"] = { cmd = "aptitude search '~U'" }, ["Fedora"] = { cmd = "yum list updates", sub = 3 }, - ["FreeBSD"] ={ cmd = "pkg_version -I -l '<'" }, + ["FreeBSD"] ={ cmd = "pkg version -I -l '<'" }, ["Mandriva"]={ cmd = "urpmq --auto-select" } } @@ -45,4 +45,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(pkg, { __call = function(_, ...) return worker(...) end }) +return setmetatable(pkg_all, { __call = function(_, ...) return worker(...) end }) From 5c7c695ea1b3e9ee9ca43820053037ec6a53a8c1 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:55:08 +0100 Subject: [PATCH 21/47] move raid widget to match new layout --- widgets/{raid.lua => raid_linux.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{raid.lua => raid_linux.lua} (93%) diff --git a/widgets/raid.lua b/widgets/raid_linux.lua similarity index 93% rename from widgets/raid.lua rename to widgets/raid_linux.lua index eafb118..c48b63a 100644 --- a/widgets/raid.lua +++ b/widgets/raid_linux.lua @@ -17,7 +17,7 @@ local string = { -- Raid: provides state information for a requested RAID array -- vicious.widgets.raid -local raid = {} +local raid_linux = {} -- Initialize function tables @@ -57,4 +57,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(raid, { __call = function(_, ...) return worker(...) end }) +return setmetatable(raid_linux, { __call = function(_, ...) return worker(...) end }) From 22d49a9e5d85f1e2223abfc6176ca42e621a69df Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:55:23 +0100 Subject: [PATCH 22/47] move thermal widget to match new layout --- widgets/thermal_freebsd.lua | 34 ++++++++++++++++++++++ widgets/{thermal.lua => thermal_linux.lua} | 4 +-- 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 widgets/thermal_freebsd.lua rename widgets/{thermal.lua => thermal_linux.lua} (93%) diff --git a/widgets/thermal_freebsd.lua b/widgets/thermal_freebsd.lua new file mode 100644 index 0000000..3387a52 --- /dev/null +++ b/widgets/thermal_freebsd.lua @@ -0,0 +1,34 @@ +-- {{{ Grab environment +local setmetatable = setmetatable +local string = { match = string.match } +local helpers = require("vicious.helpers") +-- }}} + + +-- Thermal: provides temperature levels of ACPI and coretemp thermal zones +-- vicious.widgets.thermal +local thermal_freebsd = {} + + +-- {{{ Thermal widget type +local function worker(format, warg) + if not warg then return end + if type(warg) ~= "table" then warg = { warg } end + + local thermals = {} + + for i=1, #warg do + local output = helpers.sysctl(warg[i]) + + if not output then + thermals[i] = -1 + else + thermals[i] = string.match(output, "[%d]+") + end + end + + return thermals +end +-- }}} + +return setmetatable(thermal_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/thermal.lua b/widgets/thermal_linux.lua similarity index 93% rename from widgets/thermal.lua rename to widgets/thermal_linux.lua index b77f652..513d7de 100644 --- a/widgets/thermal.lua +++ b/widgets/thermal_linux.lua @@ -15,7 +15,7 @@ local math = { floor = math.floor } -- Thermal: provides temperature levels of ACPI and coretemp thermal zones -- vicious.widgets.thermal -local thermal = {} +local thermal_linux = {} -- {{{ Thermal widget type @@ -46,4 +46,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(thermal, { __call = function(_, ...) return worker(...) end }) +return setmetatable(thermal_linux, { __call = function(_, ...) return worker(...) end }) From f86c60d2fdd846cdd943d4baef967bd0a2aaf0a5 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:55:37 +0100 Subject: [PATCH 23/47] port uptime widget to freebsd --- widgets/uptime_freebsd.lua | 30 ++++++++++++++++++++++++ widgets/{uptime.lua => uptime_linux.lua} | 4 ++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 widgets/uptime_freebsd.lua rename widgets/{uptime.lua => uptime_linux.lua} (90%) diff --git a/widgets/uptime_freebsd.lua b/widgets/uptime_freebsd.lua new file mode 100644 index 0000000..9e075e5 --- /dev/null +++ b/widgets/uptime_freebsd.lua @@ -0,0 +1,30 @@ +-- {{{ Grab environment +local tonumber = tonumber +local setmetatable = setmetatable +local math = { floor = math.floor } +local string = { match = string.match } +local helpers = require("vicious.helpers") +local os = { time = os.time } +-- }}} + + +-- Uptime: provides system uptime and load information +-- vicious.widgets.uptime +local uptime_freebsd = {} + + +-- {{{ Uptime widget type +local function worker(format) + local l1, l5, l15 = string.match(helpers.sysctl("vm.loadavg"), "{ ([%d]+%.[%d]+) ([%d]+%.[%d]+) ([%d]+%.[%d]+) }") + local up_t = os.time() - tonumber(string.match(helpers.sysctl("kern.boottime"), "sec = ([%d]+)")) + + -- Get system uptime + local up_d = math.floor(up_t / (3600 * 24)) + local up_h = math.floor((up_t % (3600 * 24)) / 3600) + local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60) + + return {up_d, up_h, up_m, l1, l5, l15} +end +-- }}} + +return setmetatable(uptime_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/uptime.lua b/widgets/uptime_linux.lua similarity index 90% rename from widgets/uptime.lua rename to widgets/uptime_linux.lua index 0e996ac..a6976b8 100644 --- a/widgets/uptime.lua +++ b/widgets/uptime_linux.lua @@ -14,7 +14,7 @@ local helpers = require("vicious.helpers") -- Uptime: provides system uptime and load information -- vicious.widgets.uptime -local uptime = {} +local uptime_linux = {} -- {{{ Uptime widget type @@ -33,4 +33,4 @@ local function worker(format) end -- }}} -return setmetatable(uptime, { __call = function(_, ...) return worker(...) end }) +return setmetatable(uptime_linux, { __call = function(_, ...) return worker(...) end }) From 54baa996c43f14be7b4c287fbae37bb04f35da71 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:56:22 +0100 Subject: [PATCH 24/47] port volume widget to freebsd --- widgets/volume_freebsd.lua | 38 ++++++++++++++++++++++++ widgets/{volume.lua => volume_linux.lua} | 4 +-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 widgets/volume_freebsd.lua rename widgets/{volume.lua => volume_linux.lua} (92%) diff --git a/widgets/volume_freebsd.lua b/widgets/volume_freebsd.lua new file mode 100644 index 0000000..200f4b7 --- /dev/null +++ b/widgets/volume_freebsd.lua @@ -0,0 +1,38 @@ +-- {{{ Grab environment +local tonumber = tonumber +local io = { popen = io.popen } +local setmetatable = setmetatable +local string = { match = string.match } +local helpers = require("vicious.helpers") +-- }}} + + +-- Volume: provides volume levels and state of requested mixer +-- vicious.widgets.volume_freebsd +local volume_freebsd = {} + + +-- {{{ Volume widget type +local function worker(format, warg) + if not warg then return end + + local mixer_state = { "♫", "♩" } + + -- Get mixer control contents + f = io.popen("mixer -s " .. helpers.shellquote(warg)) + local mixer = f:read() + f:close() + + -- Capture mixer control state: [5%] ... ... [on] + local voll, volr = string.match(mixer, "([%d]+):([%d]+)$") + + if voll == "0" and volr == "0" then + return {0, 0, mixer_state[2]} + else + return {voll, volr, mixer_state[1]} + end + +end +-- }}} + +return setmetatable(volume_freebsd, { __call = function(_, ...) return worker(...) end }) diff --git a/widgets/volume.lua b/widgets/volume_linux.lua similarity index 92% rename from widgets/volume.lua rename to widgets/volume_linux.lua index 57970a3..c7751d4 100644 --- a/widgets/volume.lua +++ b/widgets/volume_linux.lua @@ -14,7 +14,7 @@ local helpers = require("vicious.helpers") -- Volume: provides volume levels and state of requested ALSA mixers -- vicious.widgets.volume -local volume = {} +local volume_linux = {} -- {{{ Volume widget type @@ -51,4 +51,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(volume, { __call = function(_, ...) return worker(...) end }) +return setmetatable(volume_linux, { __call = function(_, ...) return worker(...) end }) From 785fefc13a5e176c2a42b49acf068ba1f0ffe33b Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:56:50 +0100 Subject: [PATCH 25/47] move wifi widget to match new layout --- widgets/{wifi.lua => wifi_linux.lua} | 4 ++-- widgets/{wifiiw.lua => wifiiw_linux.lua} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename widgets/{wifi.lua => wifi_linux.lua} (96%) rename widgets/{wifiiw.lua => wifiiw_linux.lua} (95%) diff --git a/widgets/wifi.lua b/widgets/wifi_linux.lua similarity index 96% rename from widgets/wifi.lua rename to widgets/wifi_linux.lua index 973f109..23ed396 100644 --- a/widgets/wifi.lua +++ b/widgets/wifi_linux.lua @@ -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 }) diff --git a/widgets/wifiiw.lua b/widgets/wifiiw_linux.lua similarity index 95% rename from widgets/wifiiw.lua rename to widgets/wifiiw_linux.lua index b5e28b6..82d4e3f 100644 --- a/widgets/wifiiw.lua +++ b/widgets/wifiiw_linux.lua @@ -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 }) From 602eada6527369f6308ff8a7b548f2cb038cebbe Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 17:57:16 +0100 Subject: [PATCH 26/47] move weather widget to match new layout --- widgets/{weather.lua => weather_all.lua} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename widgets/{weather.lua => weather_all.lua} (97%) diff --git a/widgets/weather.lua b/widgets/weather_all.lua similarity index 97% rename from widgets/weather.lua rename to widgets/weather_all.lua index e11e214..a5f0c4d 100644 --- a/widgets/weather.lua +++ b/widgets/weather_all.lua @@ -15,7 +15,7 @@ local helpers = require("vicious.helpers") -- Weather: provides weather information for a requested station -- vicious.widgets.weather -local weather = {} +local weather_all = {} -- Initialize function tables @@ -91,4 +91,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(weather, { __call = function(_, ...) return worker(...) end }) +return setmetatable(weather_all, { __call = function(_, ...) return worker(...) end }) From 012b67a8c080c64766135581117ac0ace831eeb8 Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 18:00:48 +0100 Subject: [PATCH 27/47] add fanspeed widget --- widgets/fanspeed_freebsd.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 widgets/fanspeed_freebsd.lua diff --git a/widgets/fanspeed_freebsd.lua b/widgets/fanspeed_freebsd.lua new file mode 100644 index 0000000..774b0da --- /dev/null +++ b/widgets/fanspeed_freebsd.lua @@ -0,0 +1,28 @@ +-- {{{ Grab environment +local setmetatable = setmetatable +local helpers = require("vicious.helpers") +local tonumber = tonumber +-- }}} + + +-- fanspeed: provides speed level of main fan +-- +-- expects one (1) full sysctl string to entry +-- e.g.: "dev.acpi_ibm.0.fan_speed" + +local fanspeed_freebsd = {} + +local function worker(format, warg) + if not warg then return end + + local fanspeed = helpers.sysctl(warg) + + if not fanspeed then + -- use negative fanspeed to indicate error + return {-1} + else + return {tonumber(fanspeed)} + end +end + +return setmetatable(fanspeed_freebsd, { __call = function(_, ...) return worker(...) end }) From fafca5d56b062d0cf3b59f97b79a4e8a6e822b2a Mon Sep 17 00:00:00 2001 From: mutlusun Date: Wed, 25 Jan 2017 18:01:08 +0100 Subject: [PATCH 28/47] README.md: update to reflect freebsd port --- README.md | 651 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 387 insertions(+), 264 deletions(-) diff --git a/README.md b/README.md index 5ae258b..fc83e89 100644 --- a/README.md +++ b/README.md @@ -5,21 +5,14 @@ catering to users of the "awesome" window manager. It was derived from the old "Wicked" widget library, and has some of the old Wicked widget types, a few of them rewritten, and a good number of new ones: - - http://git.sysphere.org/vicious/about/ +- http://git.sysphere.org/vicious/about/ Vicious widget types are a framework for creating your own widgets. Vicious contains modules that gather data about your system, and a few "awesome" helper functions that make it easier to register -timers, suspend widgets and so on. - -For now Vicious doesn't depend on any third party Lua libraries, to -make it easier to install and use. That means some system utilities -are used instead, where available: - - - hddtemp for the HDD Temperature widget type - - alsa-utils for the Volume widget type - - wireless\_tools for the Wireless widget type - - curl for widget types accessing network resources +timers, suspend widgets and so on. Vicious doesn't depend on any third party +Lua libraries, but may depend on additional system utilities (see widget +description). Usage @@ -36,6 +29,7 @@ manager (ie. Ion, WMII). It is compatible with both Lua v5.1 and v5.2. 100 ``` + Usage within Awesome -------------------- To use Vicious with Awesome, install the package from your operating @@ -63,39 +57,37 @@ vicious.register(widget, wtype, format, interval, warg) **widget** - - widget created with widget() or awful.widget() (in case of a - graph or a progressbar) +- widget created with widget() or awful.widget() (in case of a + graph or a progressbar) **wtype** - - widget type or a function - * any of the available (default, or custom) widget types can - be used here, see below for a list of those provided by - Vicious - - function - * custom functions from your own "awesome" configuration can - be registered as widget types, see the "Custom widget types" - section +- widget type or a function + * any of the available (default, or custom) widget types can be used here, + see below for a list of those provided by Vicious +- function + * custom functions from your own "awesome" configuration can be registered + as widget types, see the "Custom widget types" section **format** - - string argument or a function - * $1, $2, $3... will be replaced by their respective value - returned by the widget type, some widget types return tables - with string keys, in that case use: ${key} - - function - * function(widget, args) can be used to manipulate data - returned by the widget type, more about this below +- string argument or a function + * $1, $2, $3... will be replaced by their respective value returned by the + widget type, some widget types return tables with string keys, in that + case use: ${key} +- function + * function(widget, args) can be used to manipulate data returned by the + widget type, more about this below **interval** - - number of seconds between updates of the widget, 2s by - default, also read the "Power" section below +- number of seconds between updates of the widget, 2s by default, also read + the "Power" section below **warg** - - some widget types require an argument to be passed, for example - the battery ID +- some widget types require an argument to be passed, for example the battery + ID Other functions @@ -146,212 +138,351 @@ argument given to vicious.register as the first argument, *warg* as the second, and return a table of values to insert in the format string. +**vicious.widgets.bat** + +Provides state, charge, and remaining time for a requested battery. +Supported platforms: Linux (required tools: `sysfs`), FreeBSD (required tools: +`acpiconf`). + +- Arguments (per platform): + * Linux: takes battery ID as an argument, i.e. `"BAT0"` + * FreeBSD: takes optional battery ID as an argument, i.e. `"batt"` or `"0"` +- Returns (per platform): + * Linux: returns 1st value as state of requested battery, 2nd as charge + level in percent, 3rd as remaining (charging or discharging) time and 4th + as the wear level in percent + * FreeBSD: see Linux, but there's is 5th value for the present dis-/charge + rate in mW. + **vicious.widgets.cpu** - - provides CPU usage for all available CPUs/cores - - returns 1st value as usage of all CPUs/cores, 2nd as usage of - first CPU/core, 3rd as usage of second CPU/core etc. +Provides CPU usage for all available CPUs/cores. +Supported platforms: Linux, FreeBSD. -**vicious.widgets.cpuinf** - - - provides speed and cache information for all available CPUs/cores - - returns a table with string keys, using CPU ID as a base: - {cpu0 mhz}, {cpu0 ghz}, {cpu0 kb}, {cpu0 mb}, {cpu1 mhz} etc. +- Arguments: + * None +- Returns: + * returns 1st value as usage of all CPUs/cores, 2nd as usage of first + CPU/core, 3rd as usage of second CPU/core etc. **vicious.widgets.cpufreq** - - provides freq, voltage and governor info for a requested CPU - - takes the CPU ID as an argument, i.e. "cpu0" - - returns 1st value as frequency of requested CPU in MHz, 2nd in - GHz, 3rd as voltage in mV, 4th as voltage in V and 5th as the - governor state +Provides freq, voltage and governor info for a requested CPU. +Supported platforms: Linux, FreeBSD. -**vicious.widgets.thermal** +- Arguments (per platform): + * Linux: takes the CPU ID as an argument, i.e. `"cpu0"` + * FreeBSD: takes the CPU ID as an argument, i.e. `"0"` +- Returns (per platform): + * Linux: returns 1st value as frequency of requested CPU in MHz, 2nd in GHz, + 3rd as voltage in mV, 4th as voltage in V and 5th as the governor state + * FreeBSD: returns 1st value as frequency of requested CPU in MHz, 2nd in GHz, + 3rd as voltage in mV, 4th as voltage in V and 5th as the governor state, + but only the first two are supported (other values will be always `"N/A"`) - - provides temperature levels of ACPI and coretemp thermal zones - - takes the thermal zone as an argument, i.e. "thermal\_zone0", or a - table with 1st field as thermal zone, 2nd as data source - - available data sources are "proc", "core" and "sys" (which is the - default when only the zone is provided) and 3rd optional argument - as a temperature input file to read - - returns 1st value as temperature of requested thermal zone +**vicious.widgets.cpuinf** -**vicious.widgets.uptime** +Provides speed and cache information for all available CPUs/cores. +Supported platforms: Linux. - - provides system uptime and load information - - returns 1st value as uptime in days, 2nd as uptime in hours, 3rd - as uptime in minutes, 4th as load average for past 1 minute, 5th - for 5 minutes and 6th for 15 minutes - -**vicious.widgets.bat** - - - provides state, charge, and remaining time for a requested battery - - takes battery ID as an argument, i.e. "BAT0" - - returns 1st value as state of requested battery, 2nd as charge - level in percent, 3rd as remaining (charging or discharging) - time and 4th as the wear level in percent - -**vicious.widgets.mem** - - - provides RAM and Swap usage statistics - - returns 1st value as memory usage in percent, 2nd as memory usage, - 3rd as total system memory, 4th as free memory, 5th as swap usage - in percent, 6th as swap usage, 7th as total system swap, 8th as - free swap and 9th as memory usage with buffers and cache - -**vicious.widgets.os** - - - provides operating system information - - returns 1st value as the operating system in use, 2nd as the - release version, 3rd as your username, 4th the hostname, 5th as - available system entropy and 6th value as available entropy in - percent - -**vicious.widgets.fs** - - - provides file system disk space usage - - takes an (optional) argument which, if true, includes remote file - systems, only local file systems are included by default - - returns a table with string keys, using mount points as a base: - {/ size_mb}, {/ size_gb}, {/ used_mb}, {/ used_gb}, {/ used_p}, - {/ avail_mb}, {/ avail_gb}, {/ avail_p}, {/home size_mb} etc. - -**vicious.widgets.dio** - - - provides I/O statistics for all available storage devices - - returns a table with string keys: {sda total_s}, {sda total_kb}, - {sda total_mb}, {sda read_s}, {sda read_kb}, {sda read_mb}, - {sda write_s}, {sda write_kb}, {sda write_mb}, {sdb1 total_s} etc. - -**vicious.widgets.raid** - - - provides state information for a requested RAID array - - takes the RAID array ID as an argument - - returns 1st value as the number of assigned, and 2nd as active, - devices in the array - -**vicious.widgets.hddtemp** - - - provides hard drive temperatures using the hddtemp daemon - - takes the hddtemp listening port as an argument, or defaults to - port 7634 - - returns a table with string keys, using hard drives as a base: - {/dev/sda} and {/dev/sdc} for example - -**vicious.widgets.net** - - - provides state and usage statistics of all network interfaces - - returns a table with string keys, using net interfaces as a base: - {eth0 carrier}, {eth0 rx_b}, {eth0 tx_b}, {eth0 rx_kb}, {eth0 tx_kb}, - {eth0 rx_mb}, {eth0 tx_mb}, {eth0 rx_gb}, {eth0 tx_gb}, {eth0 down_b}, - {eth0 up_b}, {eth0 down_kb}, {eth0 up_kb}, {eth0 down_mb}, - {eth0 up_mb}, {eth0 down_gb}, {eth0 up_gb}, {eth1 rx_b} etc. - -**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) - -**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) - - -**vicious.widgets.mbox** - - - provides the subject of last e-mail in a mbox file - - takes the full path to the mbox as an argument, or a table with - 1st field as path, 2nd as maximum length and 3rd (optional) as - widget name - if 3rd field is present scrolling will be used (note: the - path will be escaped so special variables like ~ will not work, use - os.getenv("HOME").."mail" instead to access environment variables) - - returns 1st value as the subject of the last e-mail - -**vicious.widgets.mboxc** - - - provides the count of total, old and new messages in mbox files - - takes a table with full paths to mbox files as an argument - - returns 1st value as the total count of messages, 2nd as the count - of old messages and 3rd as the count of new messages - -**vicious.widgets.mdir** - - - provides the number of new and unread messages in Maildir - structures/directories - - takes a table with full paths to Maildir structures as an argument - - returns 1st value as the count of new messages and 2nd as the - count of "old" messages lacking the Seen flag - -**vicious.widgets.gmail** - - - provides count of new and subject of last e-mail on Gmail - - takes an (optional) argument, if it's a number subject will be - truncated, if a table, with 1st field as maximum length and 2nd - the widget name (i.e. "gmailwidget"), scrolling will be used - - keeps login information in the ~/.netrc file, example: - machine mail.google.com login user password pass - - returns a table with string keys: {count} and {subject} - - to be able to use this widget, make sure in your Gmail account - you disabled - [two step verification](https://support.google.com/accounts/answer/1064203) - and _then_ - [allowed access to your account for less secure apps](https://www.google.com/settings/security/lesssecureapps) - -**vicious.widgets.org** - - - provides agenda statistics for Emacs org-mode - - takes a table with full paths to agenda files, that will be - parsed, as an argument - - returns 1st value as count of tasks you forgot to do, 2nd as count - of tasks for today, 3rd as count of tasks for the next 3 days and - 4th as count of tasks to do in the week - -**vicious.widgets.pkg** - - - provides number of pending updates on UNIX systems - - takes the distribution name as an argument, i.e. "Arch" - - returns 1st value as the count of available updates - -**vicious.widgets.mpd** - - - provides Music Player Daemon information - - takes a table as an argument, 1st field should be the password (or - nil), 2nd the hostname (or nil) and 3rd port (or nil) - if no - argument is provided connection attempt will be made to localhost - port 6600 with no password - - returns a table with string keys: {volume}, {state}, {Artist}, - {Title}, {Album}, {Genre} and optionally {Name} and {file} - -**vicious.widgets.volume** - - - provides volume levels and state of requested ALSA mixers - - takes the ALSA mixer control as an argument, i.e. "Master", - optionally append the card ID or other options, i.e. "PCM -c 0" - - returns 1st value as the volume level and 2nd as the mute state of - the requested channel - -**vicious.widgets.weather** - - - provides weather information for a requested station - - takes the ICAO station code as an argument, i.e. "LDRI" - - returns a table with string keys: {city}, {wind}, {windmph}, - {windkmh}, {sky}, {weather}, {tempf}, {tempc}, {humid}, {dewf}, - {dewc}, {press} +- Arguments: + * None +- Returns: + * returns a table with string keys, using CPU ID as a base: `{cpu0 mhz}`, + `{cpu0 ghz}`, `{cpu0 kb}`, `{cpu0 mb}`, `{cpu1 mhz}` etc. **vicious.widgets.date** - - provides access to os.date, with optional time formatting provided - as the format string - using regular date sequences - - takes optional time offset, in seconds, as an argument for example - to calculate time zone differences, otherwise current time is - formatted - - returns the output of os.date, formatted by provided sequences +Provides access to os.date, with optional time formatting provided as the +format string - using regular date sequences. +Supported platforms: platform independent. + +- Arguments: + * takes optional time offset, in seconds, as an argument for example to + calculate time zone differences, otherwise current time is formatted +- Returns: + * returns the output of os.date, formatted by provided sequences + +**vicious.widgets.dio** + +Provides I/O statistics for all available storage devices. +Supported platforms: Linux. + +- Arguments: + * None +- Returns: + * returns a table with string keys: `{sda total_s}`, `{sda total_kb}`, + `{sda total_mb}`, `{sda read_s}`, `{sda read_kb}`, `{sda read_mb}`, `{sda write_s}`, + `{sda write_kb}`, `{sda write_mb}`, `{sdb1 total_s}` etc. + +**vicious.widget.fanspeed** + +Provides fanspeed information for specified fan. +Supported platforms: FreeBSD. + +- Arguments: + * Full sysctl string to entry, i.e. `"dev.acpi_ibm.0.fan_speed"` +- Returns: + * Speed of specified fan as number, `-1` for error (probably wrong string) + +**vicious.widgets.fs** + +Provides usage of file system disk space. +Supported platforms: platform independent. + +- Arguments: + * takes an (optional) argument which, if true, includes remote file systems, + only local file systems are included by default +- Returns: + * returns a table with string keys, using mount points as a base: + `{/ size_mb}`, `{/ size_gb}`, `{/ used_mb}`, `{/ used_gb}`, `{/ used_p}`, + `{/ avail_mb}`, `{/ avail_gb}`, `{/ avail_p}`, `{/home size_mb}` etc. + +**vicious.widgets.gmail** + +Provides count of new and subject of last e-mail on Gmail. +Supported platform: platform independent (required tools: `curl`). + +This widget expects login information in your `~/.netrc` file, e. g. +`machine mail.google.com login user password pass` and you have to disable +[two step verification](https://support.google.com/accounts/answer/1064203). +[Allow access for less secure apps](https://www.google.com/settings/security/lesssecureapps) +afterwards. BE AWARE THAT MAKING THESE SETTINGS IS A SECURITY RISK! + +- Arguments: + * takes an (optional) argument, if it's a number subject will be truncated, + if a table, with 1st field as maximum length and 2nd the widget name (i.e. + "gmailwidget"), scrolling will be used +- Returns: + * returns a table with string keys: {count} and {subject} + +**vicious.widgets.hddtemp** + +Provides hard drive temperatures using the hddtemp daemon. +Supported platforms: Linux (required tools: `hddtemp`, `curl`). + +- Arguments: + * takes the hddtemp listening port as an argument, or defaults to port 7634 +- Returns: + * returns a table with string keys, using hard drives as a base: `{/dev/sda}` + and `{/dev/sdc}` for example + +**vicious.widgets.mbox** + +Provides the subject of last e-mail in a mbox file. +Supported platforms: platform independent. + +- Arguments: + * takes the full path to the mbox as an argument, or a table with 1st field + as path, 2nd as maximum length and 3rd (optional) as widget name - if 3rd + field is present scrolling will be used (note: the path will be escaped so + special variables like ~ will not work, use os.getenv("HOME").."mail" + instead to access environment variables) +- Returns: + * returns 1st value as the subject of the last e-mail + +**vicious.widgets.mboxc** + +Provides the count of total, old and new messages in mbox files. +Supported platforms: platform independent. + +- Arguments: + * takes a table with full paths to mbox files as an argument +- Returns: + * returns 1st value as the total count of messages, 2nd as the count of old + messages and 3rd as the count of new messages + +**vicious.widgets.mdir** + +Provides the number of new and unread messages in Maildir +structures/directories. +Supported platforms: platform independent. + +- Arguments: + * takes a table with full paths to Maildir structures as an argument +- Returns: + * returns 1st value as the count of new messages and 2nd as the count of + "old" messages lacking the Seen flag + +**vicious.widgets.mem** + +Provides RAM and Swap usage statistics. +Supported platforms: Linux, FreeBSD. + +- Arguments: + * None +- Returns (per platform): + * Linux: returns 1st value as memory usage in percent, 2nd as memory usage, 3rd as + total system memory, 4th as free memory, 5th as swap usage in percent, 6th + as swap usage, 7th as total system swap, 8th as free swap and 9th as + memory usage with buffers and cache + * FreeBSD: see above, but 10th value as memory usage with buffers and cache + as percent and 11th value as wired memory (memory used by kernel) is + reported + +**vicious.widgets.mpd** + +Provides Music Player Daemon information. +Supported platforms: platform independent (required tools: `curl`). + +- Arguments: + * takes a table as an argument, 1st field should be the password (or nil), + 2nd the hostname (or nil) and 3rd port (or nil) - if no argument is + provided connection attempt will be made to localhost port 6600 with no + password +- Returns: + * returns a table with string keys: `{volume}`, `{state}`, `{Artist}`, `{Title}`, + `{Album}`, `{Genre}` and optionally `{Name}` and `{file}` + +**vicious.widgets.net** + +Provides state and usage statistics of network interfaces. +Supported platforms: Linux, FreeBSD. + +- Arguments (per platform): + * Linux: none + * FreeBSD: desired interface, e.g. `wlan0` +- Returns (per platform): + * Linux: returns a table with string keys, using net interfaces as a base: + `{eth0 carrier}`, `{eth0 rx_b}`, `{eth0 tx_b}`, `{eth0 rx_kb}`, `{eth0 tx_kb}`, + `{eth0 rx_mb}`, `{eth0 tx_mb}`, `{eth0 rx_gb}`, `{eth0 tx_gb}`, `{eth0 down_b}`, + `{eth0 up_b}`, `{eth0 down_kb}`, `{eth0 up_kb}`, `{eth0 down_mb}`, + `{eth0 up_mb}`, `{eth0 down_gb}`, `{eth0 up_gb}`, `{eth1 rx_b}` etc. + * FreeBSD: returns a table with string keys: + `{carrier}`, `{rx_b}`, `{tx_b}`, `{rx_kb}`, `{tx_kb}`, + `{rx_mb}`, `{tx_mb}`, `{rx_gb}`, `{tx_gb}`, `{down_b}`, + `{up_b}`, `{down_kb}`, `{up_kb}`, `{down_mb}`, + `{up_mb}`, `{down_gb}`, `{up_gb}` + +**vicious.widgets.org** + +Provides agenda statistics for Emacs org-mode. +Supported platforms: platform independent. + +- Arguments: + * takes a table with full paths to agenda files, that will be parsed, as an + argument +- Returns: + * returns 1st value as count of tasks you forgot to do, 2nd as count of + tasks for today, 3rd as count of tasks for the next 3 days and 4th as + count of tasks to do in the week + +**vicious.widgets.os** + +Provides operating system information. +Supported platforms: platform independent. + +- Arguments: + * None +- Returns: + * returns 1st value as the operating system in use, 2nd as the release + version, 3rd as your username, 4th the hostname, 5th as available system + entropy and 6th value as available entropy in percent + +**vicious.widgets.pkg** + +Provides number of pending updates on UNIX systems. Be aware that some package +managers need to update their local databases (as root) before showing the +correct number of updates. +Supported platforms: platform independent. + +- Arguments: + * takes the Linux or BSD distribution name as an argument, i.e. "Arch", + "FreeBSD" +- Returns: + * returns 1st value as the count of available updates + +**vicious.widgets.raid** + +Provides state information for a requested RAID array. +Supported platforms: Linux. + +- Arguments: + * Takes the RAID array ID as an argument +- Returns: + * Returns 1st value as the number of assigned, and 2nd as active, devices in + the array + +**vicious.widgets.thermal** + +Provides temperature levels of several thermal zones. +Supported platforms: Linux, FreeBSD. + +- Arguments (per platform): + * Linux: takes the thermal zone as an argument, i.e. `"thermal_zone0"`, or a + table with 1st field as thermal zone, 2nd as data source - available data + sources are "proc", "core" and "sys" (which is the default when only the + zone is provided) and 3rd optional argument as a temperature input file to + read + * FreeBSD: takes the full sysctl path to a thermal zone as an argument, i.e. + `"hw.acpi.thermal.tz0.temperature"`, or a table with multiple paths +- Returns: + * Linux: returns 1st value as temperature of requested thermal zone + * FreeBSD: returns a table with a entry for every input thermal zone + +**vicious.widgets.uptime** + +Provides system uptime and load information. +Supported platforms: Linux, FreeBSD. + +- Arguments: + * None +- Returns: + * Returns 1st value as uptime in days, 2nd as uptime in hours, 3rd as uptime + in minutes, 4th as load average for past 1 minute, 5th for 5 minutes and + 6th for 15 minutes + +**vicious.widgets.volume** + +Provides volume levels and state of requested mixers. +Supported platforms: Linux (required tool: amixer), FreeBSD. + +- Arguments (per platform): + * Linux: takes the ALSA mixer control as an argument, i.e. `"Master"`, + optionally append the card ID or other options, i.e. `"PCM -c 0"` + * FreeBSD: takes the mixer control as an argument, i.e. `"vol"` +- Returns: + * Linux: returns 1st value as the volume level and 2nd as the mute state of + the requested control + * FreeBSD: returns 1st value as the volume level of the left channel, 2nd as + the volume level of the right channel and 3rd as the mute state of the + desired control + +**vicious.widgets.weather** + +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"` +- Returns: + * Returns a table with string keys: `{city}`, `{wind}`, `{windmph}`, + `{windkmh}`, `{sky}`, `{weather}`, `{tempf}`, `{tempc}`, `{humid}`, + `{dewf}`, `{dewc}` and `{press}` + +**vicious.widgets.wifi** + +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** + +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 @@ -361,18 +492,12 @@ own. Write a quick worker function that does the work and plug it in. How data will be formatted, will it be red or blue, should be defined in rc.lua (or somewhere else, outside the actual module). -Before writing a widget type you should check if there is already one -in the contrib directory of Vicious. The contrib directory contains -extra widgets you can use. Some are for less common hardware, and -other were contributed by Vicious users. The contrib directory also -holds widget types that were obsoleted or rewritten. Contrib widgets -will not be imported by init unless you explicitly enable it, or load -them in your rc.lua. - -Rudi Siegel, a FreeBSD user, published his FreeBSD branch. If you are -also a BSD user you can find his work here: - - - https://bitbucket.org/mutluyum/vicious_bsd/ +Before writing a widget type you should check if there is already one in the +contrib directory of Vicious. The contrib directory contains extra widgets you +can use. Some are for less common hardware, and other were contributed by +Vicious users. Most of the contrib widgets are obsolete. Contrib widgets will +not be imported by init unless you explicitly enable it, or load them in your +rc.lua. Some users would like to avoid writing new modules. For them Vicious kept the old Wicked functionality, possibility to register their own @@ -408,17 +533,15 @@ enables you to have multiple widgets using the same widget type. With caching its worker function gets executed only once - which is also great for saving power. - - Some widget types keep internal data and if you call one multiple - times without caching, the widget that executes it first would - modify stored values. This can lead to problems and give you - inconsistent data. Remember it for widget types like CPU and - Network usage, which compare the old set of data with the new one - to calculate current usage. +- Some widget types keep internal data and if you call one multiple times + without caching, the widget that executes it first would modify stored + values. This can lead to problems and give you inconsistent data. Remember + it for widget types like CPU and Network usage, which compare the old set of + data with the new one to calculate current usage. - - Widget types that require a widget argument to be passed should be - handled carefully. If you are requesting information for different - devices then caching should not be used, because you could get - inconsistent data. +- Widget types that require a widget argument to be passed should be handled + carefully. If you are requesting information for different devices then + caching should not be used, because you could get inconsistent data. Security @@ -536,8 +659,8 @@ change it or perform some action. You can change the color of the battery widget when it goes below a certain point, hide widgets when they return a certain value or maybe use string.format for padding. - - Do not confuse this with just coloring the widget, in those cases - standard pango markup can be inserted into the format string. +- Do not confuse this with just coloring the widget, in those cases standard + pango markup can be inserted into the format string. The format function will get the widget as its first argument, table with the values otherwise inserted into the format string as its @@ -633,7 +756,7 @@ Other ----- Read *"awesome"* manual pages: - - awesome(1) awesomerc(5) +- awesome(1) awesomerc(5) [Awesome widgets explained](http://awesome.naquadah.org/wiki/Widgets_in_awesome) @@ -641,29 +764,29 @@ Read *"awesome"* manual pages: Example "awesome" configuration: - - http://git.sysphere.org/awesome-configs/ +- http://git.sysphere.org/awesome-configs/ Authors ------- Wicked written by: - - Lucas de Vries \ +- Lucas de Vries \ Vicious written by: - - Adrian C. (anrxc) \ +- Adrian C. (anrxc) \ Vicious major contributors: - - Benedikt Sauer \ - - Greg D. \ - - Henning Glawe \ - - Rémy C. \ - - Hiltjo Posthuma \ - - Hagen Schink \ - - Jörg Thalheim \ - - Arvydas Sidorenko \ - - Dodo The Last - - ... - - Consult git log for a complete list of contributors +- Benedikt Sauer \ +- Greg D. \ +- Henning Glawe \ +- Rémy C. \ +- Hiltjo Posthuma \ +- Hagen Schink \ +- Jörg Thalheim \ +- Arvydas Sidorenko \ +- Dodo The Last +- ... +- Consult git log for a complete list of contributors From 57d847301f596dd7dc46abef1ff1d92e71e12de2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:38:33 +0100 Subject: [PATCH 29/47] remove batacpi: already provied by bat_freebsd --- contrib/README | 3 --- contrib/batacpi.lua | 52 --------------------------------------------- 2 files changed, 55 deletions(-) delete mode 100644 contrib/batacpi.lua diff --git a/contrib/README b/contrib/README index a6c0416..88e15e1 100644 --- a/contrib/README +++ b/contrib/README @@ -44,9 +44,6 @@ vicious.contrib.ati {dpm_perf_level}, {profile}, {engine_clock mhz}, {engine_clock khz}, {memory_clock mhz}, {memory_clock khz}, {voltage v}, {voltage mv} -vicious.contrib.batacpi - - - vicious.contrib.batpmu - diff --git a/contrib/batacpi.lua b/contrib/batacpi.lua deleted file mode 100644 index fc7d54b..0000000 --- a/contrib/batacpi.lua +++ /dev/null @@ -1,52 +0,0 @@ ---------------------------------------------------- --- Licensed under the GNU General Public License v2 --- * (c) 2010, Adrian C. ---------------------------------------------------- - --- {{{ Grab environment -local tonumber = tonumber -local io = { popen = io.popen } -local setmetatable = setmetatable -local table = { insert = table.insert } -local string = { match = string.match } --- }}} - - --- Batacpi: provides state, charge, and remaining time for all batteries using acpitool --- vicious.contrib.batacpi -local batacpi = {} - - --- {{{ Battery widget type -local function worker(format) - local battery_info = {} - local battery_state = { - ["full"] = "↯", - ["unknown"] = "⌁", - ["charged"] = "↯", - ["charging"] = "+", - ["discharging"] = "-" - } - - -- Get data from acpitool - local f = io.popen("acpitool -b") - - for line in f:lines() do - -- Check if the battery is present - if string.match(line, "^[%s]+Battery.*") then - -- Store state and charge information - table.insert(battery_info, (battery_state[string.match(line, "([%a]*),") or "unknown"])) - table.insert(battery_info, (tonumber(string.match(line, "([%d]?[%d]?[%d])%.")) or 0)) - -- Store remaining time information - table.insert(battery_info, (string.match(line, "%%,%s(.*)") or "N/A")) - else - return {battery_state["unknown"], 0, "N/A"} - end - end - f:close() - - return battery_info -end --- }}} - -return setmetatable(batacpi, { __call = function(_, ...) return worker(...) end }) From 387ab4a8b1f08f1db9993d19f5c523a1b5ae2d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:42:04 +0100 Subject: [PATCH 30/47] move ac widget to match new layout --- contrib/{README => README.md} | 15 ++++++++++----- contrib/{ac.lua => ac_linux.lua} | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) rename contrib/{README => README.md} (94%) rename contrib/{ac.lua => ac_linux.lua} (87%) diff --git a/contrib/README b/contrib/README.md similarity index 94% rename from contrib/README rename to contrib/README.md index 88e15e1..45e266a 100644 --- a/contrib/README +++ b/contrib/README.md @@ -28,12 +28,17 @@ could also depend on Lua libraries that are not distributed with the core Lua distribution. Ease of installation and use does not necessarily have to apply to contributed widgets. -vicious.contrib.ac - - provide status about the power supply (AC) - - takes the AC device as an argument, i.e "AC" or "ACAD" - - the device is linked under /sys/class/power_supply/ and should +**vicious.contrib.ac** + +Provide status about the power supply (AC) +Supported platforms: Linux (required tools: `sysfs`) + +- Arguments: + * takes the AC device as an argument, i.e "AC" or "ACAD" + * the device is linked under /sys/class/power_supply/ and should have a file called "online" - - if AC is connected, $1 returns "On", if not it returns "Off", +- Returns + * if AC is connected, $1 returns "On", if not it returns "Off", if AC doesn't exist, $1 is "N/A" vicious.contrib.ati diff --git a/contrib/ac.lua b/contrib/ac_linux.lua similarity index 87% rename from contrib/ac.lua rename to contrib/ac_linux.lua index 48d1961..73afb03 100644 --- a/contrib/ac.lua +++ b/contrib/ac_linux.lua @@ -14,7 +14,7 @@ local math = { } -- }}} -local ac = {} +local ac_linux = {} -- {{{ AC widget type local function worker(format, warg) @@ -32,4 +32,4 @@ end -- }}} -return setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(ac_linux, { __call = function(_, ...) return worker(...) end }) From 865fe5bf5d24e1fdc37fbb6b47940a67824c07e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:45:19 +0100 Subject: [PATCH 31/47] move ati widget to match new layout --- contrib/README.md | 13 +++++++++---- contrib/{ati.lua => ati_linux.lua} | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) rename contrib/{ati.lua => ati_linux.lua} (95%) diff --git a/contrib/README.md b/contrib/README.md index 45e266a..4ed8ea2 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -41,11 +41,16 @@ Supported platforms: Linux (required tools: `sysfs`) * if AC is connected, $1 returns "On", if not it returns "Off", if AC doesn't exist, $1 is "N/A" -vicious.contrib.ati - - provides various info about ATI GPU status - - takes card ID as an argument, i.e. "card0" (and where possible, +**vicious.contrib.ati** + +Provides various info about ATI GPU status. +Supported platforms: Linux (required tools: `sysfs`) + +- Arguments: + * takes card ID as an argument, i.e. "card0" (and where possible, uses debugfs to gather data on radeon power management) - - returns a table with string keys: {method}, {dpm_state}, +- Returns: + * a table with string keys: {method}, {dpm_state}, {dpm_perf_level}, {profile}, {engine_clock mhz}, {engine_clock khz}, {memory_clock mhz}, {memory_clock khz}, {voltage v}, {voltage mv} diff --git a/contrib/ati.lua b/contrib/ati_linux.lua similarity index 95% rename from contrib/ati.lua rename to contrib/ati_linux.lua index fd9932c..1afe8f9 100644 --- a/contrib/ati.lua +++ b/contrib/ati_linux.lua @@ -17,8 +17,8 @@ local string = { -- ATI: provides various info about ATI GPU status --- vicious.widgets.ati -local ati = {} +-- vicious.contrib.ati +local ati_linux = {} -- {{{ Define variables @@ -76,4 +76,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(ati, { __call = function(_, ...) return worker(...) end }) +return setmetatable(ati_linux, { __call = function(_, ...) return worker(...) end }) From 02c20087c9c2882d8068fa5edbbb9ed6941280d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:46:47 +0100 Subject: [PATCH 32/47] move batpmu widget to match new layout --- contrib/README.md | 3 +-- contrib/{batpmu.lua => batpmu_linux.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{batpmu.lua => batpmu_linux.lua} (95%) diff --git a/contrib/README.md b/contrib/README.md index 4ed8ea2..fc642b4 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -54,8 +54,7 @@ Supported platforms: Linux (required tools: `sysfs`) {dpm_perf_level}, {profile}, {engine_clock mhz}, {engine_clock khz}, {memory_clock mhz}, {memory_clock khz}, {voltage v}, {voltage mv} -vicious.contrib.batpmu - - +**vicious.contrib.batpmu** vicious.contrib.batproc - diff --git a/contrib/batpmu.lua b/contrib/batpmu_linux.lua similarity index 95% rename from contrib/batpmu.lua rename to contrib/batpmu_linux.lua index 8c73d93..0efc863 100644 --- a/contrib/batpmu.lua +++ b/contrib/batpmu_linux.lua @@ -21,7 +21,7 @@ local string = { -- Batpmu: provides state, charge and remaining time for a requested battery using PMU -- vicious.contrib.batpmu -local batpmu = {} +local batpmu_linux = {} -- {{{ Battery widget type @@ -76,4 +76,4 @@ local function worker(format, batid) end -- }}} -return setmetatable(batpmu, { __call = function(_, ...) return worker(...) end }) +return setmetatable(batpmu_linux, { __call = function(_, ...) return worker(...) end }) From 93a0aa6649cf50f6fd68b927b57181ebc77745ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:47:47 +0100 Subject: [PATCH 33/47] mv batproc to match new layout --- contrib/README.md | 3 +-- contrib/{batproc.lua => batproc_linux.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{batproc.lua => batproc_linux.lua} (95%) diff --git a/contrib/README.md b/contrib/README.md index fc642b4..2f2fde5 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -56,8 +56,7 @@ Supported platforms: Linux (required tools: `sysfs`) **vicious.contrib.batpmu** -vicious.contrib.batproc - - +**vicious.contrib.batproc** vicious.contrib.dio - provides I/O statistics for requested storage devices diff --git a/contrib/batproc.lua b/contrib/batproc_linux.lua similarity index 95% rename from contrib/batproc.lua rename to contrib/batproc_linux.lua index 8acf005..0d4dfe7 100644 --- a/contrib/batproc.lua +++ b/contrib/batproc_linux.lua @@ -21,7 +21,7 @@ local string = { -- Batproc: provides state, charge, and remaining time for a requested battery using procfs -- vicious.contrib.batproc -local batproc = {} +local batproc_linux = {} -- {{{ Battery widget type @@ -83,4 +83,4 @@ local function worker(format, batid) end -- }}} -return setmetatable(batproc, { __call = function(_, ...) return worker(...) end }) +return setmetatable(batproc_linux, { __call = function(_, ...) return worker(...) end }) From c8c9cf690b1ce234eed703873cf2edd3c9f2863a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:49:53 +0100 Subject: [PATCH 34/47] move buildbot to match new layout --- contrib/README.md | 16 ++++++++++------ contrib/{buildbot.lua => buildbot_all.lua} | 7 ++----- 2 files changed, 12 insertions(+), 11 deletions(-) rename contrib/{buildbot.lua => buildbot_all.lua} (97%) diff --git a/contrib/README.md b/contrib/README.md index 2f2fde5..05a37ed 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -131,12 +131,16 @@ vicious.contrib.wpa - takes the interface as an argument, i.e "wlan0" or "wlan1" - returns a table with string keys: {ssid}, {qual}, {ip}, {bssid} -vicious.contrib.buildbot - - provides last build status for configured buildbot builders (http://trac.buildbot.net/) - - returns build status in the format: [..] - - if is the same as only one number is displayed - - colors: red - failed, green - successful, yellow - in progress - - it depends on lua json parser (e.g. liblua5.1-json on Ubuntu 12.04) +**vicious.contrib.buildbot** + +Provides last build status for configured buildbot builders (http://trac.buildbot.net/) +Supported Platforms: platform independent + +- Returns: + * returns build status in the format: [..] + * if is the same as only one number is displayed + * colors: red - failed, green - successful, yellow - in progress + * it depends on lua json parser (e.g. liblua5.1-json on Ubuntu 12.04) Usage examples diff --git a/contrib/buildbot.lua b/contrib/buildbot_all.lua similarity index 97% rename from contrib/buildbot.lua rename to contrib/buildbot_all.lua index 5743662..a8f1278 100644 --- a/contrib/buildbot.lua +++ b/contrib/buildbot_all.lua @@ -17,10 +17,7 @@ local bb = {} --list of all buildbot builders local bs = {OK=1, FAILED=2, RUNNING=3} local bc = {"green", "red", "yellow"} -module("vicious.contrib.buildbot") - - - +local buildbot_all = {} BB = {} BB.__index = BB @@ -182,5 +179,5 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +setmetatable(buildbot_all, { __call = function(_, ...) return worker(...) end }) From e67054dfd7c7764bb8180539ea2630c8fcd56e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:51:05 +0100 Subject: [PATCH 35/47] move countfiles widget to match new layout --- contrib/README.md | 2 ++ contrib/{countfiles.lua => countfiles_all.lua} | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) rename contrib/{countfiles.lua => countfiles_all.lua} (91%) diff --git a/contrib/README.md b/contrib/README.md index 05a37ed..ce0bbf5 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -58,6 +58,8 @@ Supported platforms: Linux (required tools: `sysfs`) **vicious.contrib.batproc** +**vicious.contrib.countfiles** + vicious.contrib.dio - provides I/O statistics for requested storage devices - takes the disk as an argument, i.e. "sda" (or a specific diff --git a/contrib/countfiles.lua b/contrib/countfiles_all.lua similarity index 91% rename from contrib/countfiles.lua rename to contrib/countfiles_all.lua index 470d932..e8f146c 100644 --- a/contrib/countfiles.lua +++ b/contrib/countfiles_all.lua @@ -17,8 +17,9 @@ local pairs = pairs -- Be carefull with directories, who contains a mass of files. -- "find" is usally fast, but will also produce delays, if the inodes get to big. -- So if you want to count your music library, you may want to use locate/updatedb instead. -module("vicious.contrib.countfiles") +-- vicious.contrib.countfiles +local countfiles_all = {} -- {{{ Sum up widget type local function worker(format, warg) @@ -47,4 +48,4 @@ local function worker(format, warg) end -- }}} -setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +setmetatable(countfiles_all, { __call = function(_, ...) return worker(...) end }) From e787aa0d68f78f884e07d2426fb13bd63ee72662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:52:52 +0100 Subject: [PATCH 36/47] move dio widget to match new layout --- contrib/README.md | 10 +++++++--- contrib/{dio.lua => dio_linux.lua} | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) rename contrib/{dio.lua => dio_linux.lua} (95%) diff --git a/contrib/README.md b/contrib/README.md index ce0bbf5..5c5d1a7 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -60,11 +60,15 @@ Supported platforms: Linux (required tools: `sysfs`) **vicious.contrib.countfiles** -vicious.contrib.dio - - provides I/O statistics for requested storage devices +**vicious.contrib.dio** + +Provides I/O statistics for requested storage devices + +- Arguments: - takes the disk as an argument, i.e. "sda" (or a specific partition, i.e. "sda/sda2") - - returns a table with string keys: {total_s}, {total_kb}, {total_mb}, +- Returns: + - a table with string keys: {total_s}, {total_kb}, {total_mb}, {read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb} and {sched} diff --git a/contrib/dio.lua b/contrib/dio_linux.lua similarity index 95% rename from contrib/dio.lua rename to contrib/dio_linux.lua index 5639bc8..3059361 100644 --- a/contrib/dio.lua +++ b/contrib/dio_linux.lua @@ -14,7 +14,7 @@ local helpers = require("vicious.helpers") -- Disk I/O: provides I/O statistics for requested storage devices -- vicious.contrib.dio -local dio = {} +local dio_linux = {} -- Initialize function tables @@ -70,4 +70,4 @@ local function worker(format, disk) end -- }}} -return setmetatable(dio, { __call = function(_, ...) return worker(...) end }) +return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end }) From 9cb3eab18fff08106434aff49b067c0bb440c2c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:53:46 +0100 Subject: [PATCH 37/47] move mpc widget to match new layout --- contrib/README.md | 3 +-- contrib/{mpc.lua => mpc_all.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{mpc.lua => mpc_all.lua} (91%) diff --git a/contrib/README.md b/contrib/README.md index 5c5d1a7..613b224 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -72,8 +72,7 @@ Provides I/O statistics for requested storage devices {read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb} and {sched} -vicious.contrib.mpc - - +**vicious.contrib.mpc** vicious.contrib.netcfg - diff --git a/contrib/mpc.lua b/contrib/mpc_all.lua similarity index 91% rename from contrib/mpc.lua rename to contrib/mpc_all.lua index 60974c0..20ce506 100644 --- a/contrib/mpc.lua +++ b/contrib/mpc_all.lua @@ -15,7 +15,7 @@ local helpers = require("vicious.helpers") -- Mpc: provides the currently playing song in MPD -- vicious.contrib.mpc -local mpc = {} +local mpc_all = {} -- {{{ MPC widget type @@ -45,4 +45,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(mpc, { __call = function(_, ...) return worker(...) end }) +return setmetatable(mpc_all, { __call = function(_, ...) return worker(...) end }) From 6b448fd7915fd774be210d83a19ad77c42d22dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 19:54:04 +0100 Subject: [PATCH 38/47] move net widget to match new layout --- contrib/README.md | 3 +-- contrib/{net.lua => net_linux.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{net.lua => net_linux.lua} (97%) diff --git a/contrib/README.md b/contrib/README.md index 613b224..cbbd184 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -77,8 +77,7 @@ Provides I/O statistics for requested storage devices vicious.contrib.netcfg - -vicious.contrib.net - - +**vicious.contrib.net** vicious.contrib.openweather - provides weather information for a requested city diff --git a/contrib/net.lua b/contrib/net_linux.lua similarity index 97% rename from contrib/net.lua rename to contrib/net_linux.lua index 5e6ba93..5ea31b4 100644 --- a/contrib/net.lua +++ b/contrib/net_linux.lua @@ -18,7 +18,7 @@ local helpers = require("vicious.helpers") -- Net: provides usage statistics for all network interfaces -- vicious.contrib.net -local net = {} +local net_linux = {} -- Initialise function tables @@ -136,4 +136,4 @@ local function worker(format, tignorelist) end -- }}} -return setmetatable(net, { __call = function(_, ...) return worker(...) end }) +return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end }) From f333c78256203b4cbb958c11773e6a93556663eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:02:28 +0100 Subject: [PATCH 39/47] move nvinf widget to match new layout --- contrib/README.md | 14 +++++++++----- contrib/{nvinf.lua => nvinf_all.lua} | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) rename contrib/{nvinf.lua => nvinf_all.lua} (89%) diff --git a/contrib/README.md b/contrib/README.md index cbbd184..db0cc83 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -85,11 +85,15 @@ vicious.contrib.openweather - returns a table with string keys: {city}, {wind deg}, {wind aim}, {wind kmh}, {wind mps}, {sky}, {weather}, {temp c}, {humid}, {press} -vicious.contrib.nvinf - - provides GPU utilization, core temperature, clock frequency information - about Nvidia GPU from nvidia-settings - - takes optional card ID as an argument, i.e. "1", or defaults to ID 0 - - returns first 4 values as usage of GPU core, memory, video engine and +**vicious.contrib.nvinf** + +provides GPU utilization, core temperature, clock frequency information about Nvidia GPU from nvidia-settings +Supported Platforms: platform independent + +- Arguments + * takes optional card ID as an argument, i.e. "1", or defaults to ID 0 +- Returns + * first 4 values as usage of GPU core, memory, video engine and PCIe bandwidth, 5th as temperature of requested graphics device, 6th as frequency of GPU core, 7th as memory transfer rate diff --git a/contrib/nvinf.lua b/contrib/nvinf_all.lua similarity index 89% rename from contrib/nvinf.lua rename to contrib/nvinf_all.lua index b277b78..35b1632 100644 --- a/contrib/nvinf.lua +++ b/contrib/nvinf_all.lua @@ -13,7 +13,7 @@ local helpers = require("vicious.helpers") -- vicious.widgets.nvinf -local nvinf = {} +local nvinf_all = {} -- {{{ NVIDIA infomation widget type @@ -32,4 +32,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(nvinf, { __call = function(_, ...) return worker(...) end }) +return setmetatable(nvinf_all, { __call = function(_, ...) return worker(...) end }) From 4882377cb3749af6db4dbfe64d10b6ab413d0f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:05:01 +0100 Subject: [PATCH 40/47] move nvsmi widget to match new layout --- contrib/README.md | 13 +++++++++---- contrib/{nvsmi.lua => nvsmi_all.lua} | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) rename contrib/{nvsmi.lua => nvsmi_all.lua} (91%) diff --git a/contrib/README.md b/contrib/README.md index db0cc83..554e89f 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -97,10 +97,15 @@ Supported Platforms: platform independent PCIe bandwidth, 5th as temperature of requested graphics device, 6th as frequency of GPU core, 7th as memory transfer rate -vicious.contrib.nvsmi - - provides (very basic) information about Nvidia GPU status from SMI - - takes optional card ID as an argument, i.e. "1", or defaults to ID 0 - - returns 1st value as temperature of requested graphics device +**vicious.contrib.nvsmi** + +Provides (very basic) information about Nvidia GPU status from SMI +Supported Platforms: platform independent + +- Arguments: + * takes optional card ID as an argument, i.e. "1", or defaults to ID 0 +- Returns: + * returns 1st value as temperature of requested graphics device vicious.contrib.ossvol - diff --git a/contrib/nvsmi.lua b/contrib/nvsmi_all.lua similarity index 91% rename from contrib/nvsmi.lua rename to contrib/nvsmi_all.lua index e68d4a1..317787e 100644 --- a/contrib/nvsmi.lua +++ b/contrib/nvsmi_all.lua @@ -13,7 +13,7 @@ local string = { match = string.match } -- nvsmi: provides GPU information from nvidia SMI -- vicious.contrib.nvsmi -local nvsmi = {} +local nvsmi_all = {} -- {{{ GPU Information widget type @@ -39,4 +39,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(nvsmi, { __call = function(_, ...) return worker(...) end }) +return setmetatable(nvsmi_all, { __call = function(_, ...) return worker(...) end }) From f63ab23583b33247afbe1abf85515215c2b32cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:06:45 +0100 Subject: [PATCH 41/47] move openweather to match new layout --- contrib/README.md | 12 ++++++++---- contrib/{openweather.lua => openweather_all.lua} | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) rename contrib/{openweather.lua => openweather_all.lua} (96%) diff --git a/contrib/README.md b/contrib/README.md index 554e89f..622ba24 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -79,10 +79,14 @@ vicious.contrib.netcfg **vicious.contrib.net** -vicious.contrib.openweather - - provides weather information for a requested city - - takes OpenWeatherMap city ID as an argument, i.e. "1275339" - - returns a table with string keys: {city}, {wind deg}, {wind aim}, +**vicious.contrib.openweather** + +Provides weather information for a requested city + +- Arguments + * takes OpenWeatherMap city ID as an argument, i.e. "1275339" +- Returns + * a table with string keys: {city}, {wind deg}, {wind aim}, {wind kmh}, {wind mps}, {sky}, {weather}, {temp c}, {humid}, {press} **vicious.contrib.nvinf** diff --git a/contrib/openweather.lua b/contrib/openweather_all.lua similarity index 96% rename from contrib/openweather.lua rename to contrib/openweather_all.lua index d3d2ffd..dfeabf7 100644 --- a/contrib/openweather.lua +++ b/contrib/openweather_all.lua @@ -17,7 +17,7 @@ local math = { -- Openweather: provides weather information for a requested station -- vicious.widgets.openweather -local openweather = {} +local openweather_all = {} -- Initialize function tables @@ -91,4 +91,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(openweather, { __call = function(_, ...) return worker(...) end }) +return setmetatable(openweather_all, { __call = function(_, ...) return worker(...) end }) From bd08badccca65ddff979f759b161d34211b4a8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:10:04 +0100 Subject: [PATCH 42/47] move pulse widget to new layout --- contrib/README.md | 40 +++++++++++++++------------- contrib/{pulse.lua => pulse_all.lua} | 8 +++--- 2 files changed, 26 insertions(+), 22 deletions(-) rename contrib/{pulse.lua => pulse_all.lua} (94%) diff --git a/contrib/README.md b/contrib/README.md index 622ba24..67f6105 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -117,24 +117,28 @@ vicious.contrib.ossvol vicious.contrib.pop - -vicious.contrib.pulse - - provides volume levels of requested pulseaudio sinks and - functions to manipulate them - - takes the name of a sink as an optional argument. a number will - be interpret as an index, if no argument is given, it will take - the first-best - - to get a list of available sinks use the command: pacmd - list-sinks | grep 'name:' - - returns 1st value as the volume level - - vicious.contrib.pulse.add(percent, sink) - - @percent is a number, which increments or decrements the volume - level by its value in percent - - @sink optional, same usage as in vicious.contrib.pulse - - returns the exit status of pacmd - - vicious.contrib.pulse.toggle(sink) - - inverts the volume state (mute -> unmute; unmute -> mute) - - @sink optional, same usage as in vicious.contrib.pulse - - returns the exit status of pacmd +**vicious.contrib.pulse** + +Provides volume levels of requested pulseaudio sinks and functions to +manipulate them + +- Arguments + * takes the name of a sink as an optional argument. a number will + be interpret as an index, if no argument is given, it will take + the first-best + * to get a list of available sinks use the command: pacmd + list-sinks | grep 'name:' +- Returns + * returns 1st value as the volume level +- vicious.contrib.pulse.add(percent, sink) + * @percent is a number, which increments or decrements the volume + level by its value in percent + * @sink optional, same usage as in vicious.contrib.pulse + * returns the exit status of pacmd +- vicious.contrib.pulse.toggle(sink) + * inverts the volume state (mute -> unmute; unmute -> mute) + * @sink optional, same usage as in vicious.contrib.pulse + * returns the exit status of pacmd vicious.contrib.rss - diff --git a/contrib/pulse.lua b/contrib/pulse_all.lua similarity index 94% rename from contrib/pulse.lua rename to contrib/pulse_all.lua index 663a6ab..5916bb1 100644 --- a/contrib/pulse.lua +++ b/contrib/pulse_all.lua @@ -26,7 +26,7 @@ local math = { -- Pulse: provides volume levels of requested pulseaudio sinks and methods to change them -- vicious.contrib.pulse -local pulse = {} +local pulse_all = {} -- {{{ Helper function local function pacmd(args) @@ -87,7 +87,7 @@ end -- }}} -- {{{ Volume control helper -function pulse.add(percent, sink) +function pulse_all.add(percent, sink) sink = get_sink_name(sink) if sink == nil then return end @@ -106,7 +106,7 @@ function pulse.add(percent, sink) return os.execute(cmd) end -function pulse.toggle(sink) +function pulse_all.toggle(sink) sink = get_sink_name(sink) if sink == nil then return end @@ -121,4 +121,4 @@ function pulse.toggle(sink) end -- }}} -return setmetatable(pulse, { __call = function(_, ...) return worker(...) end }) +return setmetatable(pulse_all, { __call = function(_, ...) return worker(...) end }) From 9325780f02c80383b65647d75aebb2f3541a5f41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:11:39 +0100 Subject: [PATCH 43/47] move ossvol widget to match new layout --- contrib/README.md | 3 +-- contrib/{ossvol.lua => ossvol_linux.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{ossvol.lua => ossvol_linux.lua} (92%) diff --git a/contrib/README.md b/contrib/README.md index 67f6105..41de938 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -111,8 +111,7 @@ Supported Platforms: platform independent - Returns: * returns 1st value as temperature of requested graphics device -vicious.contrib.ossvol - - +**vicious.contrib.ossvol** vicious.contrib.pop - diff --git a/contrib/ossvol.lua b/contrib/ossvol_linux.lua similarity index 92% rename from contrib/ossvol.lua rename to contrib/ossvol_linux.lua index a52316c..4f6af7e 100644 --- a/contrib/ossvol.lua +++ b/contrib/ossvol_linux.lua @@ -13,7 +13,7 @@ local string = { match = string.match } -- Ossvol: provides volume levels of requested OSS mixers -- vicious.contrib.ossvol -local ossvol = {} +local ossvol_linux = {} -- {{{ Volume widget type @@ -51,4 +51,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(ossvol, { __call = function(_, ...) return worker(...) end }) +return setmetatable(ossvol_linux, { __call = function(_, ...) return worker(...) end }) From 6db55c8bd00bdb326069f9858d97d2caae743ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:12:10 +0100 Subject: [PATCH 44/47] move pop widget to match new layout --- contrib/README.md | 3 +-- contrib/{pop.lua => pop_all.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{pop.lua => pop_all.lua} (92%) diff --git a/contrib/README.md b/contrib/README.md index 41de938..0fff7bf 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -113,8 +113,7 @@ Supported Platforms: platform independent **vicious.contrib.ossvol** -vicious.contrib.pop - - +**vicious.contrib.pop** **vicious.contrib.pulse** diff --git a/contrib/pop.lua b/contrib/pop_all.lua similarity index 92% rename from contrib/pop.lua rename to contrib/pop_all.lua index 0ea041b..5b6b2a6 100644 --- a/contrib/pop.lua +++ b/contrib/pop_all.lua @@ -20,7 +20,7 @@ end) -- POP: provides the count of new messages in a POP3 mailbox -- vicious.contrib.pop -local pop = {} +local pop_all = {} -- {{{ POP3 count widget type @@ -52,4 +52,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(pop, { __call = function(_, ...) return worker(...) end }) +return setmetatable(pop_all, { __call = function(_, ...) return worker(...) end }) From 46c5457e8eb95447780a768498e2a4958de58127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:12:43 +0100 Subject: [PATCH 45/47] move rss widget to match new layout --- contrib/README.md | 3 +-- contrib/{rss.lua => rss_all.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{rss.lua => rss_all.lua} (94%) diff --git a/contrib/README.md b/contrib/README.md index 0fff7bf..b7bdf30 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -138,8 +138,7 @@ manipulate them * @sink optional, same usage as in vicious.contrib.pulse * returns the exit status of pacmd -vicious.contrib.rss - - +**vicious.contrib.rss** vicious.contrib.sensors - diff --git a/contrib/rss.lua b/contrib/rss_all.lua similarity index 94% rename from contrib/rss.lua rename to contrib/rss_all.lua index dcf5cc7..75e9817 100644 --- a/contrib/rss.lua +++ b/contrib/rss_all.lua @@ -15,7 +15,7 @@ local setmetatable = setmetatable -- RSS: provides latest world news -- vicious.contrib.rss -local rss = {} +local rss_all = {} -- {{{ RSS widget type @@ -65,4 +65,4 @@ local function worker(format, input) end -- }}} -return setmetatable(rss, { __call = function(_, ...) return worker(...) end }) +return setmetatable(rss_all, { __call = function(_, ...) return worker(...) end }) From 6ca428becd340cf48d92f0c9493932a5f8248337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:13:48 +0100 Subject: [PATCH 46/47] move sensors widget to match new layout --- contrib/README.md | 3 +-- contrib/{sensors.lua => sensors_linux.lua} | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename contrib/{sensors.lua => sensors_linux.lua} (93%) diff --git a/contrib/README.md b/contrib/README.md index b7bdf30..bf1e155 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -140,8 +140,7 @@ manipulate them **vicious.contrib.rss** -vicious.contrib.sensors - - +**vicious.contrib.sensors** vicious.contrib.wpa - provides information about the wifi status diff --git a/contrib/sensors.lua b/contrib/sensors_linux.lua similarity index 93% rename from contrib/sensors.lua rename to contrib/sensors_linux.lua index 3ddeb01..eb0d14c 100644 --- a/contrib/sensors.lua +++ b/contrib/sensors_linux.lua @@ -17,7 +17,7 @@ local string = { -- Sensors: provides access to lm_sensors data -- vicious.contrib.sensors -local sensors = {} +local sensors_linux = {} -- {{{ Split helper function @@ -66,4 +66,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(sensors, { __call = function(_, ...) return worker(...) end }) +return setmetatable(sensors_linux, { __call = function(_, ...) return worker(...) end }) From 4502524a1912bb0d8759562d8e2a0386e223f9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 25 Jan 2017 20:15:56 +0100 Subject: [PATCH 47/47] move wpa widget to match new layout --- contrib/README.md | 12 ++++++++---- contrib/{wpa.lua => wpa_all.lua} | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) rename contrib/{wpa.lua => wpa_all.lua} (93%) diff --git a/contrib/README.md b/contrib/README.md index bf1e155..3cd4471 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -142,11 +142,15 @@ manipulate them **vicious.contrib.sensors** -vicious.contrib.wpa - - provides information about the wifi status - - requires 'wpa_cli' from wpa_supplicant +**vicious.contrib.wpa** + +Provides information about the wifi status +Supported Platforms: platform independent (`wpa_cli`) + +- Arguments - takes the interface as an argument, i.e "wlan0" or "wlan1" - - returns a table with string keys: {ssid}, {qual}, {ip}, {bssid} +- Returns + - a table with string keys: {ssid}, {qual}, {ip}, {bssid} **vicious.contrib.buildbot** diff --git a/contrib/wpa.lua b/contrib/wpa_all.lua similarity index 93% rename from contrib/wpa.lua rename to contrib/wpa_all.lua index f42e852..462068f 100644 --- a/contrib/wpa.lua +++ b/contrib/wpa_all.lua @@ -20,7 +20,7 @@ local string = { -- Wifi: provides wireless information for a requested interface -local wpa = {} +local wpa_all = {} local info = { ["{ssid}"] = "N/A", @@ -62,4 +62,4 @@ local function worker(format, warg) end -- }}} -return setmetatable(_M, { __call = function(_, ...) return worker(...) end }) +return setmetatable(wpa_all, { __call = function(_, ...) return worker(...) end })