Removed submodule and added the raw files.
This commit is contained in:
parent
9da8ea9542
commit
6397c554c3
96 changed files with 8176 additions and 0 deletions
49
.config/awesome/vicious/contrib/ac_linux.lua
Normal file
49
.config/awesome/vicious/contrib/ac_linux.lua
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
-- contrib/ac_linux.lua
|
||||
-- Copyright (C) 2012 jinleileiking <jinleileiking@gmail.com>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local setmetatable = setmetatable
|
||||
local string = { format = string.format }
|
||||
local helpers = require("vicious.helpers")
|
||||
local math = {
|
||||
min = math.min,
|
||||
floor = math.floor
|
||||
}
|
||||
-- }}}
|
||||
|
||||
local ac_linux = {}
|
||||
|
||||
-- {{{ AC widget type
|
||||
local function worker(format, warg)
|
||||
local ac = helpers.pathtotable("/sys/class/power_supply/"..warg)
|
||||
|
||||
local state = ac.online
|
||||
if state == nil then
|
||||
return {"N/A"}
|
||||
elseif state == "1\n" then
|
||||
return {"On"}
|
||||
else
|
||||
return {"Off"}
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
|
||||
|
||||
return setmetatable(ac_linux, { __call = function(_, ...) return worker(...) end })
|
||||
93
.config/awesome/vicious/contrib/ati_linux.lua
Normal file
93
.config/awesome/vicious/contrib/ati_linux.lua
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
-- contrib/ati_linux.lua
|
||||
-- Copyright (C) 2013 NormalRa <normalrawr gmail com>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { open = io.open }
|
||||
local setmetatable = setmetatable
|
||||
local helpers = require("vicious.helpers")
|
||||
local string = {
|
||||
sub = string.sub,
|
||||
match = string.match,
|
||||
gmatch = string.gmatch
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- ATI: provides various info about ATI GPU status
|
||||
-- vicious.contrib.ati
|
||||
local ati_linux = {}
|
||||
|
||||
|
||||
-- {{{ Define variables
|
||||
local _units = { clock = { ["khz"] = 1, ["mhz"] = 1000 },
|
||||
voltage = { ["v"] = 1, ["mv"] = 1000 } }
|
||||
local _reps = {
|
||||
["sclk"] = { name = "engine_clock", units = _units.clock, mul = 10 },
|
||||
["mclk"] = { name = "memory_clock", units = _units.clock, mul = 10 },
|
||||
["vddc"] = { name = "voltage", units = _units.voltage },
|
||||
["voltage"] = { name = "voltage", units = _units.voltage },
|
||||
["current engine clock"] = { name = "engine_clock", units = _units.clock },
|
||||
["current memory clock"] = { name = "memory_clock", units = _units.clock }
|
||||
}
|
||||
-- }}}
|
||||
|
||||
-- {{{ ATI widget type
|
||||
local function worker(format, warg)
|
||||
if not warg then return end
|
||||
|
||||
local pm = helpers.pathtotable("/sys/class/drm/"..warg.."/device")
|
||||
local _data = {}
|
||||
|
||||
-- Get power info
|
||||
_data["{method}"] =
|
||||
pm.power_method and string.sub(pm.power_method, 1, -2) or "N/A"
|
||||
_data["{dpm_state}"] =
|
||||
pm.power_dpm_state and string.sub(pm.power_dpm_state, 1, -2) or "N/A"
|
||||
_data["{dpm_perf_level}"] =
|
||||
pm.power_dpm_force_performance_level and
|
||||
string.sub(pm.power_dpm_force_performance_level, 1, -2) or "N/A"
|
||||
_data["{profile}"] =
|
||||
pm.power_profile and string.sub(pm.power_profile, 1, -2) or "N/A"
|
||||
|
||||
local f = io.open("/sys/kernel/debug/dri/64/radeon_pm_info", "r")
|
||||
if f then -- Get ATI info from the debug filesystem
|
||||
for line in f:lines() do
|
||||
for k, unit in string.gmatch(line, "(%a+[%a%s]*):[%s]+([%d]+)") do
|
||||
unit = tonumber(unit)
|
||||
|
||||
_data["{dpm_power_level}"] = -- DPM active?
|
||||
tonumber(string.match(line, "power level ([%d])")) or "N/A"
|
||||
|
||||
if _reps[k] then
|
||||
for u, v in pairs(_reps[k].units) do
|
||||
_data["{".._reps[k].name.." "..u.."}"] =
|
||||
(unit * (_reps[k].mul or 1)) / v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
end
|
||||
|
||||
return _data
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(ati_linux, { __call = function(_, ...) return worker(...) end })
|
||||
93
.config/awesome/vicious/contrib/batpmu_linux.lua
Normal file
93
.config/awesome/vicious/contrib/batpmu_linux.lua
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
-- contrib/batpmu_linux.lua
|
||||
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { open = io.open }
|
||||
local setmetatable = setmetatable
|
||||
local math = {
|
||||
min = math.min,
|
||||
floor = math.floor
|
||||
}
|
||||
local string = {
|
||||
find = string.find,
|
||||
match = string.match,
|
||||
format = string.format
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Batpmu: provides state, charge and remaining time for a requested battery using PMU
|
||||
-- vicious.contrib.batpmu
|
||||
local batpmu_linux = {}
|
||||
|
||||
|
||||
-- {{{ Battery widget type
|
||||
local function worker(format, batid)
|
||||
local battery_state = {
|
||||
["full"] = "↯",
|
||||
["unknown"] = "⌁",
|
||||
["00000013"] = "+",
|
||||
["00000011"] = "-"
|
||||
}
|
||||
|
||||
-- Get /proc/pmu/battery* state
|
||||
local f = io.open("/proc/pmu/" .. batid)
|
||||
-- Handler for incompetent users
|
||||
if not f then return {battery_state["unknown"], 0, "N/A"} end
|
||||
local statefile = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- Get /proc/pmu/info data
|
||||
local f = io.open("/proc/pmu/info")
|
||||
local infofile = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- Check if the battery is present
|
||||
if infofile == nil or string.find(infofile, "Battery count[%s]+:[%s]0") then
|
||||
return {battery_state["unknown"], 0, "N/A"}
|
||||
end
|
||||
|
||||
|
||||
-- Get capacity and charge information
|
||||
local capacity = string.match(statefile, "max_charge[%s]+:[%s]([%d]+).*")
|
||||
local remaining = string.match(statefile, "charge[%s]+:[%s]([%d]+).*")
|
||||
|
||||
-- Calculate percentage
|
||||
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||
|
||||
|
||||
-- Get timer information
|
||||
local timer = string.match(statefile, "time rem%.[%s]+:[%s]([%d]+).*")
|
||||
if timer == "0" then return {battery_state["full"], percent, "N/A"} end
|
||||
|
||||
-- Get state information
|
||||
local state = string.match(statefile, "flags[%s]+:[%s]([%d]+).*")
|
||||
local state = battery_state[state] or battery_state["unknown"]
|
||||
|
||||
-- Calculate remaining (charging or discharging) time
|
||||
local hoursleft = math.floor(tonumber(timer) / 3600)
|
||||
local minutesleft = math.floor((tonumber(timer) / 60) % 60)
|
||||
local time = string.format("%02d:%02d", hoursleft, minutesleft)
|
||||
|
||||
return {state, percent, time}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(batpmu_linux, { __call = function(_, ...) return worker(...) end })
|
||||
100
.config/awesome/vicious/contrib/batproc_linux.lua
Normal file
100
.config/awesome/vicious/contrib/batproc_linux.lua
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
-- contrib/batproc_linux.lua
|
||||
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { open = io.open }
|
||||
local setmetatable = setmetatable
|
||||
local math = {
|
||||
min = math.min,
|
||||
floor = math.floor
|
||||
}
|
||||
local string = {
|
||||
find = string.find,
|
||||
match = string.match,
|
||||
format = string.format
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Batproc: provides state, charge, and remaining time for a requested battery using procfs
|
||||
-- vicious.contrib.batproc
|
||||
local batproc_linux = {}
|
||||
|
||||
|
||||
-- {{{ Battery widget type
|
||||
local function worker(format, batid)
|
||||
local battery_state = {
|
||||
["full"] = "↯",
|
||||
["unknown"] = "⌁",
|
||||
["charged"] = "↯",
|
||||
["charging"] = "+",
|
||||
["discharging"] = "-"
|
||||
}
|
||||
|
||||
-- Get /proc/acpi/battery info
|
||||
local f = io.open("/proc/acpi/battery/"..batid.."/info")
|
||||
-- Handler for incompetent users
|
||||
if not f then return {battery_state["unknown"], 0, "N/A"} end
|
||||
local infofile = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- Check if the battery is present
|
||||
if infofile == nil or string.find(infofile, "present:[%s]+no") then
|
||||
return {battery_state["unknown"], 0, "N/A"}
|
||||
end
|
||||
|
||||
-- Get capacity information
|
||||
local capacity = string.match(infofile, "last full capacity:[%s]+([%d]+).*")
|
||||
|
||||
|
||||
-- Get /proc/acpi/battery state
|
||||
local f = io.open("/proc/acpi/battery/"..batid.."/state")
|
||||
local statefile = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- Get state information
|
||||
local state = string.match(statefile, "charging state:[%s]+([%a]+).*")
|
||||
local state = battery_state[state] or battery_state["unknown"]
|
||||
|
||||
-- Get charge information
|
||||
local rate = string.match(statefile, "present rate:[%s]+([%d]+).*")
|
||||
local remaining = string.match(statefile, "remaining capacity:[%s]+([%d]+).*")
|
||||
|
||||
|
||||
-- Calculate percentage (but work around broken BAT/ACPI implementations)
|
||||
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||
|
||||
-- Calculate remaining (charging or discharging) time
|
||||
if state == "+" then
|
||||
timeleft = (tonumber(capacity) - tonumber(remaining)) / tonumber(rate)
|
||||
elseif state == "-" then
|
||||
timeleft = tonumber(remaining) / tonumber(rate)
|
||||
else
|
||||
return {state, percent, "N/A"}
|
||||
end
|
||||
local hoursleft = math.floor(timeleft)
|
||||
local minutesleft = math.floor((timeleft - hoursleft) * 60 )
|
||||
local time = string.format("%02d:%02d", hoursleft, minutesleft)
|
||||
|
||||
return {state, percent, time}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(batproc_linux, { __call = function(_, ...) return worker(...) end })
|
||||
70
.config/awesome/vicious/contrib/btc_all.lua
Normal file
70
.config/awesome/vicious/contrib/btc_all.lua
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
-- contrib/btc_all.lua
|
||||
-- Copyright (C) 2017 0x5b <dragen15051@gmail.com>
|
||||
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
|
||||
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local pcall = pcall
|
||||
local helpers = require("vicious.helpers")
|
||||
local spawn = require("vicious.spawn")
|
||||
|
||||
local success, json = pcall(require, "cjson")
|
||||
if not success then
|
||||
json = require("json")
|
||||
end
|
||||
|
||||
local string = {
|
||||
sub = string.sub,
|
||||
upper = string.upper,
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Btc: provides current bitcoin price
|
||||
-- vicious.widgets.btc
|
||||
local btc_all = {}
|
||||
|
||||
|
||||
-- {{ Bitcoin widget type
|
||||
function btc_all.async(format, warg, callback)
|
||||
-- Default values
|
||||
if not warg then warg = "usd" end
|
||||
|
||||
local btc = { ["{price}"] = "N/A" }
|
||||
local currency_code = string.upper(warg)
|
||||
local url = "https://api.coindesk.com/v1/bpi/currentprice/" .. currency_code .. ".json"
|
||||
local cmd = "curl "..helpers.shellquote(url)
|
||||
|
||||
-- {{ Checking response
|
||||
local function parse(response)
|
||||
-- If 'response' is not json, 'json.decode' will return Error
|
||||
local status, data = pcall(function() return json.decode(response) end)
|
||||
if not status or not data then
|
||||
return btc
|
||||
end
|
||||
|
||||
btc["{price}"] = string.sub(data["bpi"][currency_code]["rate"], 0, -3)
|
||||
return btc
|
||||
end
|
||||
-- }}
|
||||
|
||||
spawn.easy_async(cmd, function(stdout) callback(parse(stdout)) end)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return helpers.setasyncall(btc_all)
|
||||
197
.config/awesome/vicious/contrib/buildbot_all.lua
Normal file
197
.config/awesome/vicious/contrib/buildbot_all.lua
Normal file
|
|
@ -0,0 +1,197 @@
|
|||
-- contrib/buildbot_all.lua
|
||||
-- Copyright (C) 2012 Andrzje Bieniek <andyhelp@gmail.com>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local setmetatable = setmetatable
|
||||
local pcall = pcall
|
||||
local json_status, json = pcall(require, "json")
|
||||
local io = { popen = io.popen }
|
||||
local pairs = pairs
|
||||
local assert = assert
|
||||
-- }}}
|
||||
|
||||
local bb = {} --list of all buildbot builders
|
||||
|
||||
local bs = {OK=1, FAILED=2, RUNNING=3}
|
||||
local bc = {"green", "red", "yellow"}
|
||||
|
||||
local buildbot_all = {}
|
||||
|
||||
BB = {}
|
||||
BB.__index = BB
|
||||
|
||||
function BB.create(url, builder)
|
||||
local b = {}
|
||||
setmetatable(b,BB)
|
||||
b.url = url -- buildbot url
|
||||
b.builder = builder -- builder name
|
||||
b.lastChecked = 0 -- last checked build number
|
||||
b.lastSuccessful = 0 -- last successful build number
|
||||
b.lastResult = nil -- last json parsed result
|
||||
b.lastError = nil -- last error string or nil if no error
|
||||
return b
|
||||
end
|
||||
|
||||
function BB:_queryBuildbot(build_number)
|
||||
local f = io.popen("curl --connect-timeout 1 "..self.url.."/json/builders/"..self.builder.."/builds/"..build_number)
|
||||
local jsbuilder = f:read("*all")
|
||||
f:close()
|
||||
if #jsbuilder == 0 then
|
||||
return false, "can't read from url"
|
||||
end
|
||||
|
||||
local result_status, result = pcall(json.decode, jsbuilder, false)
|
||||
if not result_status then
|
||||
return false, "can't parse json data"
|
||||
end
|
||||
return true, result
|
||||
end
|
||||
|
||||
function BB:_getBuildStatus(result)
|
||||
if #result['text'] > 0 then
|
||||
local text = result['text']
|
||||
if text[1] == "build" and text[2] == "successful" and #text == 2 then
|
||||
--successful
|
||||
return bs.OK
|
||||
else
|
||||
--failed
|
||||
return bs.FAILED
|
||||
end
|
||||
else
|
||||
--in progress
|
||||
return bs.RUNNING
|
||||
end
|
||||
end
|
||||
|
||||
-- Function queries buildbot to refresh builds status.
|
||||
-- * if build is successful or failed it will not be queried again, number is stored in lasteChecked
|
||||
-- * up to 10 last builds will be checked to find last successful build
|
||||
function BB:refresh()
|
||||
local last_pass_fail = 0
|
||||
local nr = -1
|
||||
local last_result
|
||||
local iter_counter = 0
|
||||
|
||||
self.lastError = nil
|
||||
self.lastResult = nil
|
||||
--- there is a gap to fill in, iterate all not checked builds starting from latest
|
||||
while nr > self.lastChecked or nr == -1 do
|
||||
local r_status, r = self:_queryBuildbot(nr)
|
||||
local s
|
||||
|
||||
if not r_status then
|
||||
self.lastError = r
|
||||
return
|
||||
end
|
||||
|
||||
s = self:_getBuildStatus(r)
|
||||
if not last_result then
|
||||
last_result = r
|
||||
end
|
||||
nr = r['number']
|
||||
assert(nr > 0)
|
||||
if last_pass_fail == 0 and (s == bs.OK or s == bs.FAILED) then
|
||||
last_pass_fail = nr
|
||||
end
|
||||
if s == bs.OK then --successful
|
||||
self.lastSuccessful = nr
|
||||
break;
|
||||
end
|
||||
nr = nr - 1
|
||||
iter_counter = iter_counter + 1
|
||||
if iter_counter > 10 then --check max last 10 builds when searching for successful build
|
||||
break;
|
||||
end
|
||||
end
|
||||
if last_pass_fail ~= 0 then
|
||||
self.lastChecked = last_pass_fail
|
||||
end
|
||||
if last_result then
|
||||
self.lastResult = last_result
|
||||
end
|
||||
end
|
||||
|
||||
function BB:getLastSuccessful()
|
||||
return self.lastSuccessful
|
||||
end
|
||||
|
||||
function BB:getCurrent()
|
||||
return self.lastResult['number']
|
||||
end
|
||||
|
||||
function BB:getCurrentStatus()
|
||||
return self:_getBuildStatus(self.lastResult)
|
||||
end
|
||||
|
||||
function BB:getBuilder()
|
||||
return self.builder
|
||||
end
|
||||
|
||||
function BB:getError()
|
||||
return self.lastError
|
||||
end
|
||||
|
||||
|
||||
local function getBuilderStatus(b)
|
||||
local s = "[" .. b:getBuilder()
|
||||
--check if json library was loaded correctly
|
||||
if not json_status then
|
||||
return s .. ".<span color=\"orange\">can't find libluaX.X-json</span>]"
|
||||
end
|
||||
|
||||
local err = b:getError()
|
||||
if err then
|
||||
return s .. ".<span color=\"orange\">" .. err .. "</span>]"
|
||||
end
|
||||
|
||||
if b:getLastSuccessful() ~= 0 then
|
||||
success_build_nr_str = "<span color=\"green\">".. b:getLastSuccessful() .."</span>"
|
||||
else
|
||||
success_build_nr_str = "-"
|
||||
end
|
||||
|
||||
local current_build_color = bc[b:getCurrentStatus()]
|
||||
current_build_nr_str = "<span color=\""..current_build_color.."\">"..b:getCurrent().."</span>"
|
||||
|
||||
if current_build_color ~= "green" then
|
||||
s = s .. "." .. current_build_nr_str
|
||||
end
|
||||
return s .. "." .. success_build_nr_str .. "]"
|
||||
end
|
||||
|
||||
|
||||
-- {{{ Buildbot widget type
|
||||
local function worker(format, warg)
|
||||
if #bb == 0 then --fill up bb with builders when worker function is run for the first time
|
||||
for i,v in pairs(warg) do
|
||||
bb[#bb+1] = BB.create(v["url"], v["builder"])
|
||||
end
|
||||
end
|
||||
|
||||
local str = ""
|
||||
for i,v in pairs(bb) do
|
||||
v:refresh()
|
||||
str = str .. " " .. getBuilderStatus(v)
|
||||
end
|
||||
return {str .. " "}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
setmetatable(buildbot_all, { __call = function(_, ...) return worker(...) end })
|
||||
|
||||
1
.config/awesome/vicious/contrib/cmus_all.lua
Symbolic link
1
.config/awesome/vicious/contrib/cmus_all.lua
Symbolic link
|
|
@ -0,0 +1 @@
|
|||
../widgets/cmus_all.lua
|
||||
64
.config/awesome/vicious/contrib/countfiles_all.lua
Normal file
64
.config/awesome/vicious/contrib/countfiles_all.lua
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
-- contrib/countfiles_all.lua
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local pairs = pairs
|
||||
-- }}}
|
||||
|
||||
-- countfiles: provides a number of files in several directories
|
||||
-- @warg.paths a table with the paths which should be checked
|
||||
-- @warg.pattern a global regex to match files (Default: match all)
|
||||
-- use posix-egrep style instead of the default (less familiar) emacs regex
|
||||
|
||||
-- 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.
|
||||
|
||||
-- vicious.contrib.countfiles
|
||||
local countfiles_all = {}
|
||||
|
||||
-- {{{ Sum up widget type
|
||||
local function worker(format, warg)
|
||||
if not warg then return end
|
||||
-- Initialise counter table
|
||||
local store = {}
|
||||
|
||||
-- Match by default all files
|
||||
warg.pattern = warg.pattern or ".*"
|
||||
|
||||
for key, value in pairs(warg.paths) do
|
||||
local f = io.popen("find '"..value.."'"..
|
||||
" -type f -regextype posix-egrep"..
|
||||
" -regex '"..warg.pattern.."'")
|
||||
|
||||
local lines = 0
|
||||
for line in f:lines() do
|
||||
lines = lines + 1
|
||||
end
|
||||
|
||||
store[key] = (store[key] or 0) + lines
|
||||
|
||||
f:close()
|
||||
end
|
||||
return store
|
||||
end
|
||||
-- }}}
|
||||
|
||||
setmetatable(countfiles_all, { __call = function(_, ...) return worker(...) end })
|
||||
87
.config/awesome/vicious/contrib/dio_linux.lua
Normal file
87
.config/awesome/vicious/contrib/dio_linux.lua
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
-- contrib/dio_linux.lua
|
||||
-- Copyright (C) 2010, Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local ipairs = ipairs
|
||||
local setmetatable = setmetatable
|
||||
local table = { insert = table.insert }
|
||||
local string = { gmatch = string.gmatch }
|
||||
local helpers = require("vicious.helpers")
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Disk I/O: provides I/O statistics for requested storage devices
|
||||
-- vicious.contrib.dio
|
||||
local dio_linux = {}
|
||||
|
||||
|
||||
-- Initialize function tables
|
||||
local disk_usage = {}
|
||||
local disk_total = {}
|
||||
-- Variable definitions
|
||||
local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
|
||||
|
||||
-- {{{ Disk I/O widget type
|
||||
local function worker(format, disk)
|
||||
if not disk then return end
|
||||
|
||||
local disk_lines = { [disk] = {} }
|
||||
local disk_stats = helpers.pathtotable("/sys/block/" .. disk)
|
||||
|
||||
if disk_stats.stat then
|
||||
local match = string.gmatch(disk_stats.stat, "[%s]+([%d]+)")
|
||||
for i = 1, 11 do -- Store disk stats
|
||||
table.insert(disk_lines[disk], match())
|
||||
end
|
||||
end
|
||||
|
||||
-- Ensure tables are initialized correctly
|
||||
local diff_total = { [disk] = {} }
|
||||
if not disk_total[disk] then
|
||||
disk_usage[disk] = {}
|
||||
disk_total[disk] = {}
|
||||
|
||||
while #disk_total[disk] < #disk_lines[disk] do
|
||||
table.insert(disk_total[disk], 0)
|
||||
end
|
||||
end
|
||||
|
||||
for i, v in ipairs(disk_lines[disk]) do
|
||||
-- Diskstats are absolute, substract our last reading
|
||||
diff_total[disk][i] = v - disk_total[disk][i]
|
||||
|
||||
-- Store totals
|
||||
disk_total[disk][i] = v
|
||||
end
|
||||
|
||||
-- Calculate and store I/O
|
||||
helpers.uformat(disk_usage[disk], "read", diff_total[disk][3], unit)
|
||||
helpers.uformat(disk_usage[disk], "write", diff_total[disk][7], unit)
|
||||
helpers.uformat(disk_usage[disk], "total", diff_total[disk][7] + diff_total[disk][3], unit)
|
||||
|
||||
-- Store I/O scheduler
|
||||
if disk_stats.queue and disk_stats.queue.scheduler then
|
||||
disk_usage[disk]["{sched}"] = string.gmatch(disk_stats.queue.scheduler, "%[([%a]+)%]")
|
||||
end
|
||||
|
||||
return disk_usage[disk]
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end })
|
||||
31
.config/awesome/vicious/contrib/init.lua
Normal file
31
.config/awesome/vicious/contrib/init.lua
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
-- contrib/init.lua
|
||||
-- Copyright (C) 2010-2012 Adrian C. (anrxc) <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2011 Joerg T. (Mic92) <jthalheim@gmail.com>
|
||||
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Setup environment
|
||||
local setmetatable = setmetatable
|
||||
local wrequire = require("vicious.helpers").wrequire
|
||||
|
||||
-- Vicious: widgets for the awesome window manager
|
||||
-- vicious.contrib
|
||||
local contrib = { _NAME = "vicious.contrib" }
|
||||
-- }}}
|
||||
|
||||
-- Load modules at runtime as needed
|
||||
return setmetatable(contrib, { __index = wrequire })
|
||||
63
.config/awesome/vicious/contrib/mpc_all.lua
Normal file
63
.config/awesome/vicious/contrib/mpc_all.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
-- contrib/mpc_all.lua
|
||||
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
-- Copyright (C) 2018 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local type = type
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local string = { find = string.find }
|
||||
local helpers = require("vicious.helpers")
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Mpc: provides the currently playing song in MPD
|
||||
-- vicious.contrib.mpc
|
||||
local mpc_all = {}
|
||||
|
||||
|
||||
-- {{{ MPC widget type
|
||||
local function worker(format, warg)
|
||||
-- Get data from mpd
|
||||
local f = io.popen("mpc")
|
||||
local np = f:read("*line")
|
||||
f:close()
|
||||
|
||||
-- Not installed,
|
||||
if np == nil or -- off or stoppped.
|
||||
(string.find(np, "MPD_HOST") or string.find(np, "volume:"))
|
||||
then
|
||||
return {"Stopped"}
|
||||
end
|
||||
|
||||
-- Check if we should scroll, or maybe truncate
|
||||
if warg then
|
||||
if type(warg) == "table" then
|
||||
np = helpers.scroll(np, warg[1], warg[2])
|
||||
else
|
||||
np = helpers.truncate(np, warg)
|
||||
end
|
||||
end
|
||||
|
||||
return {np}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(mpc_all, { __call = function(_, ...) return worker(...) end })
|
||||
154
.config/awesome/vicious/contrib/net_linux.lua
Normal file
154
.config/awesome/vicious/contrib/net_linux.lua
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
-- contrib/net_linux.lua
|
||||
-- Copyright (C) 2009 Henning Glawe <glaweh@debian.org>
|
||||
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
-- Copyright (C) 2017 Roberto <empijei@users.noreply.github.com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local pairs = pairs
|
||||
local tonumber = tonumber
|
||||
local os = { time = os.time }
|
||||
local io = { lines = io.lines }
|
||||
local setmetatable = setmetatable
|
||||
local string = { match = string.match }
|
||||
local helpers = require("vicious.helpers")
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Net: provides usage statistics for all network interfaces
|
||||
-- vicious.contrib.net
|
||||
local net_linux = {}
|
||||
|
||||
|
||||
-- Initialise 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, tignorelist)
|
||||
local args = {}
|
||||
local tignore = {}
|
||||
local total_rx = 0
|
||||
local total_tx = 0
|
||||
local any_up = 0
|
||||
|
||||
if not tignorelist then
|
||||
tignorelist = {"lo", "wmaster0"}
|
||||
end
|
||||
for k, i in pairs(tignorelist) do
|
||||
tignore[i] = true
|
||||
end
|
||||
|
||||
-- Get NET stats
|
||||
for line in io.lines("/proc/net/dev") do
|
||||
-- Match wmaster0 as well as rt0 (multiple leading spaces)
|
||||
local name = string.match(line, "^[%s]?[%s]?[%s]?[%s]?([%w]+):")
|
||||
if name ~= nil then
|
||||
-- Received bytes, first value after the name
|
||||
local recv = tonumber(string.match(line, ":[%s]*([%d]+)"))
|
||||
-- Transmited bytes, 7 fields from end of the line
|
||||
local send = tonumber(string.match(line,
|
||||
"([%d]+)%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d$"))
|
||||
|
||||
if not tignore[name] then
|
||||
total_rx = total_rx + recv
|
||||
total_tx = total_tx + send
|
||||
end
|
||||
|
||||
helpers.uformat(args, name .. " rx", recv, unit)
|
||||
helpers.uformat(args, name .. " tx", send, unit)
|
||||
|
||||
if nets[name] == nil then
|
||||
-- Default values on the first run
|
||||
nets[name] = {}
|
||||
|
||||
helpers.uformat(args, name .. " down", 0, unit)
|
||||
helpers.uformat(args, name .. " up", 0, unit)
|
||||
args["{"..name.." carrier}"] = 0
|
||||
|
||||
nets[name].time = os.time()
|
||||
else -- Net stats are absolute, substract our last reading
|
||||
local interval = os.time() - nets[name].time > 0 and
|
||||
os.time() - nets[name].time or 1
|
||||
nets[name].time = os.time()
|
||||
|
||||
local down = (recv - nets[name][1]) / interval
|
||||
local up = (send - nets[name][2]) / interval
|
||||
|
||||
helpers.uformat(args, name .. " down", down, unit)
|
||||
helpers.uformat(args, name .. " up", up, unit)
|
||||
|
||||
-- Carrier detection
|
||||
sysnet = helpers.pathtotable("/sys/class/net/" .. name)
|
||||
|
||||
if sysnet.carrier then
|
||||
ccarrier = tonumber(sysnet.carrier)
|
||||
|
||||
args["{"..name.." carrier}"] = ccarrier
|
||||
if ccarrier == 1 and not tignore[name] then
|
||||
any_up = 1
|
||||
end
|
||||
else
|
||||
args["{"..name.." carrier}"] = 0
|
||||
end
|
||||
end
|
||||
|
||||
-- Store totals
|
||||
nets[name][1] = recv
|
||||
nets[name][2] = send
|
||||
end
|
||||
end
|
||||
|
||||
helpers.uformat(args, "total rx", total_rx, unit)
|
||||
helpers.uformat(args, "total tx", total_tx, unit)
|
||||
|
||||
if nets["total"] == nil then
|
||||
-- Default values on the first run
|
||||
nets["total"] = {}
|
||||
|
||||
helpers.uformat(args, "total down", 0, unit)
|
||||
helpers.uformat(args, "total up", 0, unit)
|
||||
args["{total carrier}"] = 0
|
||||
|
||||
nets["total"].time = os.time()
|
||||
else -- Net stats are absolute, substract our last reading
|
||||
local interval = os.time() - nets["total"].time > 0 and
|
||||
os.time() - nets["total"].time or 1
|
||||
nets["total"].time = os.time()
|
||||
|
||||
local down = (total_rx - nets["total"][1]) / interval
|
||||
local up = (total_tx - nets["total"][2]) / interval
|
||||
|
||||
helpers.uformat(args, "total down", down, unit)
|
||||
helpers.uformat(args, "total up", up, unit)
|
||||
args["{total carrier}"] = any_up
|
||||
end
|
||||
|
||||
-- Store totals
|
||||
nets["total"][1] = total_rx
|
||||
nets["total"][2] = total_tx
|
||||
|
||||
return args
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end })
|
||||
50
.config/awesome/vicious/contrib/netcfg.lua
Normal file
50
.config/awesome/vicious/contrib/netcfg.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
-- contrib/netcfg.lua
|
||||
-- Copyright (C) 2010 Radu A. <admiral0@tuxfamily.org>
|
||||
-- Copyright (C) 2010 Adrian C. (anrxc) <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2012 Arvydas Sidorenko <asido4@gmail.com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local table = { insert = table.insert }
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Netcfg: provides active netcfg network profiles
|
||||
-- vicious.contrib.netcfg
|
||||
local netcfg = {}
|
||||
|
||||
|
||||
-- {{{ Netcfg widget type
|
||||
local function worker(format)
|
||||
-- Initialize counters
|
||||
local profiles = {}
|
||||
|
||||
local f = io.popen("ls -1 /var/run/network/profiles")
|
||||
for line in f:lines() do
|
||||
if line ~= nil then
|
||||
table.insert(profiles, line)
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
|
||||
return profiles
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(netcfg, { __call = function(_, ...) return worker(...) end })
|
||||
49
.config/awesome/vicious/contrib/nvinf_all.lua
Normal file
49
.config/awesome/vicious/contrib/nvinf_all.lua
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
-- contrib/nvinf_all.lua
|
||||
-- Copyright (C) 2015 Ziyuan Guo <s10e.cn@gmail.com>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { popen = io.popen }
|
||||
local string = { gmatch = string.gmatch }
|
||||
local setmetatable = setmetatable
|
||||
local helpers = require("vicious.helpers")
|
||||
-- }}}
|
||||
|
||||
|
||||
-- vicious.widgets.nvinf
|
||||
local nvinf_all = {}
|
||||
|
||||
|
||||
-- {{{ NVIDIA infomation widget type
|
||||
local function worker(format, warg)
|
||||
if not warg then warg = "0" end
|
||||
local nv_inf = {}
|
||||
local f = io.popen("LC_ALL=C nvidia-settings -q GPUUtilization -q [gpu:"..helpers.shellquote(warg).."]/GPUCoreTemp -q [gpu:"..helpers.shellquote(warg).."]/GPUCurrentClockFreqs -t")
|
||||
local all_info = f:read("*all")
|
||||
f:close()
|
||||
|
||||
for num in string.gmatch(all_info, "%d+") do
|
||||
nv_inf[#nv_inf + 1] = tonumber(num)
|
||||
end
|
||||
|
||||
return nv_inf
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(nvinf_all, { __call = function(_, ...) return worker(...) end })
|
||||
56
.config/awesome/vicious/contrib/nvsmi_all.lua
Normal file
56
.config/awesome/vicious/contrib/nvsmi_all.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
-- contrib/nvsmi_all.lua
|
||||
-- Copyright (C) 2014 Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local string = { match = string.match }
|
||||
-- }}}
|
||||
|
||||
|
||||
-- nvsmi: provides GPU information from nvidia SMI
|
||||
-- vicious.contrib.nvsmi
|
||||
local nvsmi_all = {}
|
||||
|
||||
|
||||
-- {{{ GPU Information widget type
|
||||
local function worker(format, warg)
|
||||
-- Fallback to querying first device
|
||||
if not warg then warg = "0" end
|
||||
|
||||
-- Get data from smi
|
||||
-- * Todo: support more; MEMORY,UTILIZATION,ECC,POWER,CLOCK,COMPUTE,PIDS,PERFORMANCE
|
||||
local f = io.popen("nvidia-smi -q -d TEMPERATURE -i " .. warg)
|
||||
local smi = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- Not installed
|
||||
if smi == nil then return {0} end
|
||||
|
||||
-- Get temperature information
|
||||
local _thermal = string.match(smi, "Gpu[%s]+:[%s]([%d]+)[%s]C")
|
||||
-- Handle devices without data
|
||||
if _thermal == nil then return {0} end
|
||||
|
||||
return {tonumber(_thermal)}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(nvsmi_all, { __call = function(_, ...) return worker(...) end })
|
||||
121
.config/awesome/vicious/contrib/openweather_all.lua
Normal file
121
.config/awesome/vicious/contrib/openweather_all.lua
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
-- contrib/openweather_all.lua
|
||||
-- Copyright (C) 2013 NormalRa <normalrawr gmail com>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
-- Copyright (C) 2020 Marcel Arpogaus <marcel.arpogaus gmail com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local string = {match = string.match}
|
||||
local math = {ceil = math.ceil, floor = math.floor}
|
||||
local helpers = require "vicious.helpers"
|
||||
local spawn = require "vicious.spawn"
|
||||
-- }}}
|
||||
|
||||
-- Openweather: provides weather information for a requested station
|
||||
-- vicious.widgets.openweather
|
||||
local openweather_all = {}
|
||||
|
||||
-- Initialize function tables
|
||||
local _wdirs = {"N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"}
|
||||
local _wdata = {
|
||||
["{city}"] = "N/A",
|
||||
["{wind deg}"] = "N/A",
|
||||
["{wind aim}"] = "N/A",
|
||||
["{wind mps}"] = "N/A",
|
||||
["{wind kmh}"] = "N/A",
|
||||
["{sky}"] = "N/A",
|
||||
["{weather}"] = "N/A",
|
||||
["{temp c}"] = "N/A",
|
||||
["{temp min c}"] = "N/A",
|
||||
["{temp max c}"] = "N/A",
|
||||
["{sunrise}"] = -1,
|
||||
["{sunset}"] = -1,
|
||||
["{humid}"] = "N/A",
|
||||
["{press}"] = "N/A"
|
||||
}
|
||||
|
||||
-- {{{ Openweather widget type
|
||||
local function parse(stdout, stderr, exitreason, exitcode)
|
||||
-- Check if there was a timeout or a problem with the station
|
||||
if stdout == nil or exitcode ~= 0 then return _wdata end
|
||||
|
||||
_wdata["{city}"] = -- City name
|
||||
string.match(stdout, '"name":"([%a%s%-]+)"') or _wdata["{city}"]
|
||||
_wdata["{wind deg}"] = -- Wind degrees
|
||||
string.match(stdout, '"deg":([%d]+)') or _wdata["{wind deg}"]
|
||||
_wdata["{wind mps}"] = -- Wind speed in meters per second
|
||||
string.match(stdout, '"speed":([%d%.]+)') or _wdata["{wind mps}"]
|
||||
_wdata["{sky}"] = -- Sky conditions
|
||||
string.match(stdout, '"main":"([%a]+)"') or _wdata["{sky}"]
|
||||
_wdata["{weather}"] = -- Weather description
|
||||
string.match(stdout, '"description":"([%a%s]+)"') or _wdata["{weather}"]
|
||||
_wdata["{temp c}"] = -- Temperature in celsius
|
||||
string.match(stdout, '"temp":([%-]?[%d%.]+)') or _wdata["{temp c}"]
|
||||
_wdata["{temp min c}"] = -- Minimal Temperature in celsius
|
||||
string.match(stdout, '"temp_min":([%-]?[%d%.]+)') or _wdata["{temp min c}"]
|
||||
_wdata["{temp max c}"] = -- Maximal Temperature in celsius
|
||||
string.match(stdout, '"temp_max":([%-]?[%d%.]+)') or _wdata["{temp max c}"]
|
||||
_wdata["{humid}"] = -- Relative humidity in percent
|
||||
string.match(stdout, '"humidity":([%d]+)') or _wdata["{humid}"]
|
||||
_wdata["{sunrise}"] = -- Sunrise
|
||||
tonumber(string.match(stdout, '"sunrise":([%d]+)')) or _wdata["{sunrise}"]
|
||||
_wdata["{sunset}"] = -- Sunset
|
||||
tonumber(string.match(stdout, '"sunset":([%d]+)')) or _wdata["{sunset}"]
|
||||
_wdata["{press}"] = -- Pressure in hPa
|
||||
string.match(stdout, '"pressure":([%d%.]+)') or _wdata["{press}"]
|
||||
|
||||
-- Wind speed in km/h
|
||||
if _wdata["{wind mps}"] ~= "N/A" then
|
||||
_wdata["{wind mps}"] = math.floor(tonumber(_wdata["{wind mps}"]) + .5)
|
||||
_wdata["{wind kmh}"] = math.ceil(_wdata["{wind mps}"] * 3.6)
|
||||
end -- Temperature in °C
|
||||
if _wdata["{temp c}"] ~= "N/A" then
|
||||
_wdata["{temp c}"] = math.floor(tonumber(_wdata["{temp c}"]) + .5)
|
||||
end -- Calculate wind direction
|
||||
if _wdata["{wind deg}"] ~= "N/A" then
|
||||
_wdata["{wind deg}"] = tonumber(_wdata["{wind deg}"])
|
||||
|
||||
-- Lua tables start at [1]
|
||||
if (_wdata["{wind deg}"] / 45) % 1 == 0 then
|
||||
_wdata["{wind aim}"] = _wdirs[_wdata["{wind deg}"] / 45 + 1]
|
||||
else
|
||||
_wdata["{wind aim}"] = _wdirs[math.ceil(_wdata["{wind deg}"] / 45) +
|
||||
1] ..
|
||||
_wdirs[math.floor(
|
||||
_wdata["{wind deg}"] / 45) + 1]
|
||||
end
|
||||
end
|
||||
|
||||
return _wdata
|
||||
end
|
||||
|
||||
function openweather_all.async(format, warg, callback)
|
||||
if not warg then return callback {} end
|
||||
if type(warg) ~= "table" then return callback {} end
|
||||
|
||||
-- Get weather forceast using the city ID code, from:
|
||||
-- * OpenWeatherMap.org
|
||||
local openweather = "http://api.openweathermap.org/data/2.5/weather?id=" ..
|
||||
warg.city_id .. "&appid=" .. warg.app_id ..
|
||||
"&mode=json&units=metric"
|
||||
|
||||
spawn.easy_async("curl --connect-timeout 1 -fsm 3 '" .. openweather .. "'",
|
||||
function(...) callback(parse(...)) end)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return helpers.setasyncall(openweather_all)
|
||||
68
.config/awesome/vicious/contrib/ossvol_linux.lua
Normal file
68
.config/awesome/vicious/contrib/ossvol_linux.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
-- contrib/ossvol_linux.lua
|
||||
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local string = { match = string.match }
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Ossvol: provides volume levels of requested OSS mixers
|
||||
-- vicious.contrib.ossvol
|
||||
local ossvol_linux = {}
|
||||
|
||||
|
||||
-- {{{ Volume widget type
|
||||
local function worker(format, warg)
|
||||
if not warg then return end
|
||||
|
||||
local mixer_state = {
|
||||
["on"] = "♫", -- "",
|
||||
["off"] = "♩" -- "M"
|
||||
}
|
||||
|
||||
-- Get mixer control contents
|
||||
local f = io.popen("ossmix -c")
|
||||
local mixer = f:read("*all")
|
||||
f:close()
|
||||
|
||||
-- Capture mixer control state
|
||||
local volu = tonumber(string.match(mixer, warg .. "[%s]([%d%.]+)"))/0.25
|
||||
local mute = string.match(mixer, "vol%.mute[%s]([%a]+)")
|
||||
-- Handle mixers without data
|
||||
if volu == nil then
|
||||
return {0, mixer_state["off"]}
|
||||
end
|
||||
|
||||
-- Handle mixers without mute
|
||||
if mute == "OFF" and volu == "0"
|
||||
-- Handle mixers that are muted
|
||||
or mute == "ON" then
|
||||
mute = mixer_state["off"]
|
||||
else
|
||||
mute = mixer_state["on"]
|
||||
end
|
||||
|
||||
return {volu, mute}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(ossvol_linux, { __call = function(_, ...) return worker(...) end })
|
||||
71
.config/awesome/vicious/contrib/pop_all.lua
Normal file
71
.config/awesome/vicious/contrib/pop_all.lua
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
-- contrib/pop_all.lua
|
||||
-- Copyright (c) 2010 Boris Bolgradov
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---------------------------------------------------
|
||||
-- This widget type depends on luasocket.
|
||||
--
|
||||
-- Widget arguments are host, port, username and
|
||||
-- password, i.e.:
|
||||
-- {"mail.myhost.com", 110, "John", "132435"}
|
||||
---------------------------------------------------
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local setmetatable = setmetatable
|
||||
local sock_avail, socket = pcall(function()
|
||||
return require("socket")
|
||||
end)
|
||||
-- }}}
|
||||
|
||||
|
||||
-- POP: provides the count of new messages in a POP3 mailbox
|
||||
-- vicious.contrib.pop
|
||||
local pop_all = {}
|
||||
|
||||
|
||||
-- {{{ POP3 count widget type
|
||||
local function worker(format, warg)
|
||||
if not sock_avail or (not warg or #warg ~= 4) then
|
||||
return {"N/A"}
|
||||
end
|
||||
|
||||
local host, port = warg[1], tonumber(warg[2])
|
||||
local user, pass = warg[3], warg[4]
|
||||
|
||||
local client = socket.tcp()
|
||||
client:settimeout(3)
|
||||
client:connect(host, port)
|
||||
client:receive("*l")
|
||||
client:send("USER " .. user .. "\r\n")
|
||||
client:receive("*l")
|
||||
client:send("PASS " .. pass .. "\r\n")
|
||||
client:receive("*l")
|
||||
client:send("STAT" .. "\r\n")
|
||||
local response = client:receive("*l")
|
||||
client:close()
|
||||
|
||||
if response:find("%+OK") then
|
||||
response = response:match("%+OK (%d+)")
|
||||
end
|
||||
|
||||
return {response}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(pop_all, { __call = function(_, ...) return worker(...) end })
|
||||
139
.config/awesome/vicious/contrib/pulse_all.lua
Normal file
139
.config/awesome/vicious/contrib/pulse_all.lua
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
-- contrib/pulse_all.lua
|
||||
-- Copyright (C) 2010 MrMagne <mr.magne@yahoo.fr>
|
||||
-- Copyright (C) 2010,2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
-- Copyright (C) 2017 Jonathan McCrohan <jmccrohan@gmail.com>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local type = type
|
||||
local tonumber = tonumber
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local os = { execute = os.execute }
|
||||
local table = { insert = table.insert }
|
||||
local string = {
|
||||
find = string.find,
|
||||
match = string.match,
|
||||
format = string.format,
|
||||
gmatch = string.gmatch
|
||||
}
|
||||
local math = {
|
||||
floor = math.floor,
|
||||
ceil = math.ceil
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Pulse: provides volume levels of requested pulseaudio sinks and methods to change them
|
||||
-- vicious.contrib.pulse
|
||||
local pulse_all = {}
|
||||
|
||||
-- {{{ Helper function
|
||||
local function pacmd(args)
|
||||
local f = io.popen("pacmd "..args)
|
||||
if f == nil then
|
||||
return nil
|
||||
else
|
||||
local line = f:read("*all")
|
||||
f:close()
|
||||
return line
|
||||
end
|
||||
end
|
||||
|
||||
local function escape(text)
|
||||
local special_chars = { ["."] = "%.", ["-"] = "%-" }
|
||||
return text:gsub("[%.%-]", special_chars)
|
||||
end
|
||||
|
||||
local cached_sinks = {}
|
||||
local function get_sink_name(sink)
|
||||
if type(sink) == "string" then return sink end
|
||||
-- avoid nil keys
|
||||
local key = sink or 1
|
||||
-- Cache requests
|
||||
if not cached_sinks[key] then
|
||||
local line = pacmd("list-sinks")
|
||||
if line == nil then return nil end
|
||||
for s in string.gmatch(line, "name: <(.-)>") do
|
||||
table.insert(cached_sinks, s)
|
||||
end
|
||||
end
|
||||
|
||||
return cached_sinks[key]
|
||||
end
|
||||
|
||||
|
||||
-- }}}
|
||||
|
||||
-- {{{ Pulseaudio widget type
|
||||
local function worker(format, sink)
|
||||
sink = get_sink_name(sink)
|
||||
if sink == nil then return {0, "unknown"} end
|
||||
|
||||
-- Get sink data
|
||||
local data = pacmd("dump")
|
||||
if sink == nil then return {0, "unknown"} end
|
||||
|
||||
-- If mute return 0 (not "Mute") so we don't break progressbars
|
||||
if string.find(data,"set%-sink%-mute "..escape(sink).." yes") then
|
||||
return {0, "off"}
|
||||
end
|
||||
|
||||
local vol = tonumber(string.match(data, "set%-sink%-volume "..escape(sink).." (0x[%x]+)"))
|
||||
if vol == nil then vol = 0 end
|
||||
volpercent = vol/0x10000*100
|
||||
|
||||
return { volpercent % 1 >= 0.5 and math.ceil(volpercent) or math.floor(volpercent), "on"}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
-- {{{ Volume control helper
|
||||
function pulse_all.add(percent, sink)
|
||||
sink = get_sink_name(sink)
|
||||
if sink == nil then return end
|
||||
|
||||
local data = pacmd("dump")
|
||||
|
||||
local pattern = "set%-sink%-volume "..escape(sink).." (0x[%x]+)"
|
||||
local initial_vol = tonumber(string.match(data, pattern))
|
||||
|
||||
local vol = initial_vol + percent/100*0x10000
|
||||
if vol > 0x10000 then vol = 0x10000 end
|
||||
if vol < 0 then vol = 0 end
|
||||
|
||||
vol = math.ceil(vol)
|
||||
|
||||
local cmd = string.format("pacmd set-sink-volume %s 0x%x >/dev/null", sink, vol)
|
||||
return os.execute(cmd)
|
||||
end
|
||||
|
||||
function pulse_all.toggle(sink)
|
||||
sink = get_sink_name(sink)
|
||||
if sink == nil then return end
|
||||
|
||||
local data = pacmd("dump")
|
||||
local pattern = "set%-sink%-mute "..escape(sink).." (%a%a%a?)"
|
||||
local mute = string.match(data, pattern)
|
||||
|
||||
-- 0 to enable a sink or 1 to mute it.
|
||||
local state = { yes = 0, no = 1}
|
||||
local cmd = string.format("pacmd set-sink-mute %s %d", sink, state[mute])
|
||||
return os.execute(cmd)
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(pulse_all, { __call = function(_, ...) return worker(...) end })
|
||||
84
.config/awesome/vicious/contrib/rss_all.lua
Normal file
84
.config/awesome/vicious/contrib/rss_all.lua
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
-- contrib/rss_all.lua
|
||||
-- Copyright (C) 2009 olcc
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
---------------------------------------------------
|
||||
-- This is now a standalone RSS reader for awesome:
|
||||
-- * http://github.com/olcc/aware
|
||||
---------------------------------------------------
|
||||
|
||||
-- {{{ Grab environment
|
||||
local pairs = pairs
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
-- }}}
|
||||
|
||||
|
||||
-- RSS: provides latest world news
|
||||
-- vicious.contrib.rss
|
||||
local rss_all = {}
|
||||
|
||||
|
||||
-- {{{ RSS widget type
|
||||
local function worker(format, input)
|
||||
-- input: * feed - feed url
|
||||
-- * object - entity to look for (typically: 'item')
|
||||
-- * fields - fields to read (example: 'link', 'title', 'description')
|
||||
-- output: * count - number of entities found
|
||||
-- * one table for each field, containing wanted values
|
||||
local feed = input.feed
|
||||
local object = input.object
|
||||
local fields = input.fields
|
||||
|
||||
-- Initialise tables
|
||||
local out = {}
|
||||
|
||||
for _, v in pairs(fields) do
|
||||
out[v] = {}
|
||||
end
|
||||
|
||||
-- Initialise variables
|
||||
local ob = nil
|
||||
local i,j,k = 1, 1, 0
|
||||
local curl = "curl -A 'Mozilla/4.0' -fsm 5 --connect-timeout 3 "
|
||||
|
||||
-- Get the feed
|
||||
local f = io.popen(curl .. '"' .. feed .. '"')
|
||||
local feed = f:read("*all")
|
||||
f:close()
|
||||
|
||||
while true do
|
||||
i, j, ob = feed.find(feed, "<" .. object .. ">(.-)</" .. object .. ">", i)
|
||||
if not ob then break end
|
||||
|
||||
for _, v in pairs(fields) do
|
||||
out[v][k] = ob:match("<" .. v .. ">(.*)</" .. v .. ">")
|
||||
end
|
||||
|
||||
k = k+1
|
||||
i = j+1
|
||||
end
|
||||
|
||||
-- Update the entity count
|
||||
out.count = k
|
||||
|
||||
return out
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(rss_all, { __call = function(_, ...) return worker(...) end })
|
||||
83
.config/awesome/vicious/contrib/sensors_linux.lua
Normal file
83
.config/awesome/vicious/contrib/sensors_linux.lua
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
-- contrib/sensors_linux.lua
|
||||
-- Copyright (C) 2010 Greg D. <jabbas@jabbas.pl>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local io = { popen = io.popen }
|
||||
local setmetatable = setmetatable
|
||||
local table = { insert = table.insert }
|
||||
local string = {
|
||||
gsub = string.gsub,
|
||||
match = string.match
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Sensors: provides access to lm_sensors data
|
||||
-- vicious.contrib.sensors
|
||||
local sensors_linux = {}
|
||||
|
||||
|
||||
-- {{{ Split helper function
|
||||
local function datasplit(str)
|
||||
-- Splitting strings into associative array
|
||||
-- with some magic to get the values right.
|
||||
str = string.gsub(str, "\n", ":")
|
||||
|
||||
local tbl = {}
|
||||
string.gsub(str, "([^:]*)", function (v)
|
||||
if string.match(v, ".") then
|
||||
table.insert(tbl, v)
|
||||
end
|
||||
end)
|
||||
|
||||
local assoc = {}
|
||||
for c = 1, #tbl, 2 do
|
||||
local k = string.gsub(tbl[c], ".*_", "")
|
||||
local v = tonumber(string.match(tbl[c+1], "[%d]+"))
|
||||
assoc[k] = v
|
||||
end
|
||||
|
||||
return assoc
|
||||
end
|
||||
-- }}}
|
||||
|
||||
-- {{{ Sensors widget type
|
||||
local function worker(format, warg)
|
||||
-- Get data from all sensors
|
||||
local f = io.popen("LANG=C sensors -uA")
|
||||
local lm_sensors = f:read("*all")
|
||||
f:close()
|
||||
|
||||
local sensor_data = string.gsub(
|
||||
string.match(lm_sensors, warg..":\n(%s%s.-)\n[^ ]"), " ", "")
|
||||
|
||||
-- One of: crit, max
|
||||
local divisor = "crit"
|
||||
local s_data = datasplit(sensor_data)
|
||||
|
||||
if s_data[divisor] and s_data[divisor] > 0 then
|
||||
s_data.percent = s_data.input / s_data[divisor] * 100
|
||||
end
|
||||
|
||||
return {s_data.input, tonumber(s_data.percent)}
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(sensors_linux, { __call = function(_, ...) return worker(...) end })
|
||||
79
.config/awesome/vicious/contrib/wpa_all.lua
Normal file
79
.config/awesome/vicious/contrib/wpa_all.lua
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
-- contrib/wpa_all.lua
|
||||
-- Copyright (C) 2012 jinleileiking <jinleileiking@gmail.com>
|
||||
-- Copyright (C) 2017 Jörg Thalheim <joerg@higgsboson.tk>
|
||||
--
|
||||
-- This file is part of Vicious.
|
||||
--
|
||||
-- Vicious is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as
|
||||
-- published by the Free Software Foundation, either version 2 of the
|
||||
-- License, or (at your option) any later version.
|
||||
--
|
||||
-- Vicious is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-- {{{ Grab environment
|
||||
local tonumber = tonumber
|
||||
local math = { ceil = math.ceil }
|
||||
local setmetatable = setmetatable
|
||||
local helpers = require("vicious.helpers")
|
||||
local io = {
|
||||
open = io.open,
|
||||
popen = io.popen
|
||||
}
|
||||
local string = {
|
||||
find = string.find,
|
||||
match = string.match
|
||||
}
|
||||
-- }}}
|
||||
|
||||
|
||||
-- Wifi: provides wireless information for a requested interface
|
||||
local wpa_all = {}
|
||||
|
||||
local info = {
|
||||
["{ssid}"] = "N/A",
|
||||
["{bssid}"] = "N/A",
|
||||
["{ip}"] = "N/A",
|
||||
["{qual}"] = "N/A",
|
||||
}
|
||||
|
||||
-- {{{ Wireless widget type
|
||||
local function worker(format, warg)
|
||||
if not warg then return info end
|
||||
|
||||
local wpa_cmd = "wpa_cli -i'" .. warg .. "' status 2>&1"
|
||||
local f = io.popen(wpa_cmd)
|
||||
local output = f:read("*all")
|
||||
f:close()
|
||||
|
||||
if not output then return info end
|
||||
|
||||
state = string.match(output, 'wpa_state=([%a]+)') or 'N/A'
|
||||
info["{bssid}"] = string.match(output, 'bssid=([%d%a:]+)') or 'N/A'
|
||||
info["{ssid}"] = string.match(output, 'ssid=([%a]+)') or 'N/A'
|
||||
info["{ip}"] = string.match(output, 'ip_address=([%d.]+)') or 'N/A'
|
||||
|
||||
if not state == 'COMPLETED' then
|
||||
return info
|
||||
end
|
||||
|
||||
local wpa_cmd = "wpa_cli -i'" .. warg .. "' bss " .. bssid .. " 2>&1"
|
||||
local f = io.popen(wpa_cmd)
|
||||
local output = f:read("*all")
|
||||
f:close()
|
||||
|
||||
if not output then return info end
|
||||
|
||||
info["{qual}"] = string.match(output, 'qual=([%d]+)')
|
||||
|
||||
return info
|
||||
end
|
||||
-- }}}
|
||||
|
||||
return setmetatable(wpa_all, { __call = function(_, ...) return worker(...) end })
|
||||
Loading…
Add table
Add a link
Reference in a new issue