Update some copyright headers along with style change
Additionall introduce helpers.setcall to replace the cumbersome setmetatable at the end of most synchronous widget types
This commit is contained in:
parent
08170d67ff
commit
f54f1a7d8e
|
@ -16,6 +16,7 @@ Added:
|
||||||
- `helpers.setasyncall` to avoid writing redundant workers for asynchronous
|
- `helpers.setasyncall` to avoid writing redundant workers for asynchronous
|
||||||
widget types. Note that these workers are only needed in case Vicious is used
|
widget types. Note that these workers are only needed in case Vicious is used
|
||||||
as a stand-alone library.
|
as a stand-alone library.
|
||||||
|
- `helpers.setcall` for registering functions as widget types.
|
||||||
- `headergen` script for automatic generation of copyright notices.
|
- `headergen` script for automatic generation of copyright notices.
|
||||||
|
|
||||||
Fixed:
|
Fixed:
|
||||||
|
|
|
@ -122,6 +122,13 @@ function helpers.wrequire(collection, key)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
-- {{{ Set widget type's __call metamethod to given worker function
|
||||||
|
function helpers.setcall(wtype, worker)
|
||||||
|
return setmetatable(
|
||||||
|
wtype, { __call = function(_, ...) return worker(...) end })
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
-- {{{ Set __call metamethod to widget type table having async key
|
-- {{{ Set __call metamethod to widget type table having async key
|
||||||
function helpers.setasyncall(wtype)
|
function helpers.setasyncall(wtype)
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
-- battery widget type for FreeBSD
|
||||||
|
-- Copyright (C) 2017-2019 mutlusun <mutlusun@github.com>
|
||||||
|
-- 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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
|
|
|
@ -1,26 +1,40 @@
|
||||||
---------------------------------------------------
|
-- battery widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2013 NormalRa <normalrawr@gmail.com>
|
||||||
-- * (c) 2013, NormalRa <normalrawr@gmail.com>
|
-- Copyright (C) 2017 David Udelson <dru5@cornell.edu>
|
||||||
---------------------------------------------------
|
-- Copyright (C) 2017 Roberto <empijei@users.noreply.github.com>
|
||||||
|
-- Copyright (C) 2017 mutlusun <mutlusun@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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { format = string.format }
|
local string = { format = string.format }
|
||||||
local helpers = require("vicious.helpers")
|
|
||||||
local math = {
|
local math = {
|
||||||
min = math.min,
|
min = math.min,
|
||||||
floor = math.floor
|
floor = math.floor
|
||||||
}
|
}
|
||||||
-- }}}
|
|
||||||
|
|
||||||
|
local helpers = require"vicious.helpers"
|
||||||
|
-- }}}
|
||||||
|
|
||||||
-- Bat: provides state, charge, remaining time, and wear for a requested battery
|
-- Bat: provides state, charge, remaining time, and wear for a requested battery
|
||||||
-- vicious.widgets.bat
|
-- vicious.widgets.bat
|
||||||
local bat_linux = {}
|
local bat_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Battery widget type
|
-- {{{ Battery widget type
|
||||||
local function worker(format, warg)
|
local function worker(format, warg)
|
||||||
if not warg then return end
|
if not warg then return end
|
||||||
|
@ -45,11 +59,11 @@ local function worker(format, warg)
|
||||||
return {battery_state["Unknown\n"], 0, "N/A", 0, curpower}
|
return {battery_state["Unknown\n"], 0, "N/A", 0, curpower}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Get state information
|
-- Get state information
|
||||||
local state = battery_state[battery.status] or battery_state["Unknown\n"]
|
local state = battery_state[battery.status] or battery_state["Unknown\n"]
|
||||||
|
|
||||||
-- Get capacity information
|
-- Get capacity information
|
||||||
|
local remaining, capacity, capacity_design
|
||||||
if battery.charge_now then
|
if battery.charge_now then
|
||||||
remaining, capacity = battery.charge_now, battery.charge_full
|
remaining, capacity = battery.charge_now, battery.charge_full
|
||||||
capacity_design = battery.charge_full_design or capacity
|
capacity_design = battery.charge_full_design or capacity
|
||||||
|
@ -64,8 +78,8 @@ local function worker(format, warg)
|
||||||
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
local percent = math.min(math.floor(remaining / capacity * 100), 100)
|
||||||
local wear = math.floor(100 - capacity / capacity_design * 100)
|
local wear = math.floor(100 - capacity / capacity_design * 100)
|
||||||
|
|
||||||
|
|
||||||
-- Get charge information
|
-- Get charge information
|
||||||
|
local rate
|
||||||
if battery.current_now then
|
if battery.current_now then
|
||||||
rate = tonumber(battery.current_now)
|
rate = tonumber(battery.current_now)
|
||||||
elseif battery.power_now then
|
elseif battery.power_now then
|
||||||
|
@ -78,6 +92,7 @@ local function worker(format, warg)
|
||||||
local time = "N/A"
|
local time = "N/A"
|
||||||
|
|
||||||
if rate ~= nil and rate ~= 0 then
|
if rate ~= nil and rate ~= 0 then
|
||||||
|
local timeleft
|
||||||
if state == "+" then
|
if state == "+" then
|
||||||
timeleft = (tonumber(capacity)-tonumber(remaining)) / tonumber(rate)
|
timeleft = (tonumber(capacity)-tonumber(remaining)) / tonumber(rate)
|
||||||
elseif state == "-" then
|
elseif state == "-" then
|
||||||
|
@ -97,4 +112,4 @@ local function worker(format, warg)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(bat_linux, { __call = function(_, ...) return worker(...) end })
|
return helpers.setcall(bat_linux, worker)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
-- bat_openbsd.lua - provide battery information on OpenBSD
|
-- battery widget type for OpenBSD
|
||||||
-- Copyright (C) 2019 Enric Morales
|
-- Copyright (C) 2019 Enric Morales <me@enric.me>
|
||||||
-- Copyright (C) 2019 Nguyễn Gia Phong
|
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
|
||||||
--
|
--
|
||||||
-- This file is part of Vicious.
|
-- This file is part of Vicious.
|
||||||
--
|
--
|
||||||
|
@ -12,9 +12,9 @@
|
||||||
-- Vicious is distributed in the hope that it will be useful,
|
-- Vicious is distributed in the hope that it will be useful,
|
||||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
-- GNU Affero General Public License for more details.
|
-- GNU General Public License for more details.
|
||||||
--
|
--
|
||||||
-- You should have received a copy of the GNU Affero General Public License
|
-- You should have received a copy of the GNU General Public License
|
||||||
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
-- along with Vicious. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
-- {{{ Grab environment
|
-- {{{ Grab environment
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
-----------------------------------------------------------
|
-- cmus music player widget type
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2017 JuanKman94 <juan.carlos.menonita@gmail.com>
|
||||||
-- * (c) 2017, JuanKman94 <juan.carlos.menonita@gmail.com>
|
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
|
||||||
-----------------------------------------------------------
|
-- Copyright (C) 2018-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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
-- CPU usage widget type for FreeBSD
|
||||||
|
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
|
||||||
|
-- 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
|
-- {{{ Grab environment
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local string = { gmatch = string.gmatch }
|
local string = { gmatch = string.gmatch }
|
||||||
|
@ -5,7 +24,6 @@ local string = { gmatch = string.gmatch }
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Cpu: provides CPU usage for all available CPUs/cores
|
-- Cpu: provides CPU usage for all available CPUs/cores
|
||||||
-- vicious.widgets.cpu_freebsd
|
-- vicious.widgets.cpu_freebsd
|
||||||
local cpu_freebsd = {}
|
local cpu_freebsd = {}
|
||||||
|
|
|
@ -1,28 +1,41 @@
|
||||||
---------------------------------------------------
|
-- CPU usage widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2011, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2011 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- Copyright (C) 2011 Jörg Thalheim <jthalheim@gmail.com>
|
||||||
-- * (c) 2011, Jörg Thalheim <jthalheim@gmail.com>
|
-- Copyright (C) 2017 mutlusun <mutlusun@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
|
-- {{{ Grab environment
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local io = { open = io.open }
|
local io = { open = io.open }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local math = { floor = math.floor }
|
local math = { floor = math.floor }
|
||||||
local table = { insert = table.insert }
|
local table = { insert = table.insert }
|
||||||
local string = {
|
local string = {
|
||||||
sub = string.sub,
|
sub = string.sub,
|
||||||
gmatch = string.gmatch
|
gmatch = string.gmatch
|
||||||
}
|
}
|
||||||
-- }}}
|
|
||||||
|
|
||||||
|
local helpers = require"vicious.helpers"
|
||||||
|
-- }}}
|
||||||
|
|
||||||
-- Cpu: provides CPU usage for all available CPUs/cores
|
-- Cpu: provides CPU usage for all available CPUs/cores
|
||||||
-- vicious.widgets.cpu
|
-- vicious.widgets.cpu
|
||||||
local cpu_linux = {}
|
local cpu_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
local cpu_usage = {}
|
local cpu_usage = {}
|
||||||
local cpu_total = {}
|
local cpu_total = {}
|
||||||
|
@ -52,7 +65,6 @@ local function worker(format)
|
||||||
cpu_active[i] = 0
|
cpu_active[i] = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
for i, v in ipairs(cpu_lines) do
|
for i, v in ipairs(cpu_lines) do
|
||||||
-- Calculate totals
|
-- Calculate totals
|
||||||
local total_new = 0
|
local total_new = 0
|
||||||
|
@ -77,4 +89,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpu_linux, { __call = function(_, ...) return worker(...) end })
|
return helpers.setcall(cpu_linux, worker)
|
||||||
|
|
|
@ -1,14 +1,31 @@
|
||||||
|
-- CPU frequency widget type for FreeBSD
|
||||||
|
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
|
||||||
|
-- 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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
||||||
-- vicious.widgets.cpufreq
|
-- vicious.widgets.cpufreq
|
||||||
local cpufreq_freebsd = {}
|
local cpufreq_freebsd = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU frequency widget type
|
-- {{{ CPU frequency widget type
|
||||||
function cpufreq_freebsd.async(format, warg, callback)
|
function cpufreq_freebsd.async(format, warg, callback)
|
||||||
if not warg then return callback({}) end
|
if not warg then return callback({}) end
|
||||||
|
|
|
@ -1,33 +1,45 @@
|
||||||
---------------------------------------------------
|
-- CPU frequency widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2017 mutlusun <mutlusun@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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { match = string.match }
|
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
-- Cpufreq: provides freq, voltage and governor info for a requested CPU
|
||||||
-- vicious.widgets.cpufreq
|
-- vicious.widgets.cpufreq
|
||||||
local cpufreq_linux = {}
|
local cpufreq_linux = {}
|
||||||
|
|
||||||
|
local GOVERNOR_STATE = {
|
||||||
-- {{{ CPU frequency widget type
|
|
||||||
local function worker(format, warg)
|
|
||||||
if not warg then return end
|
|
||||||
|
|
||||||
local _cpufreq = helpers.pathtotable("/sys/devices/system/cpu/"..warg.."/cpufreq")
|
|
||||||
local governor_state = {
|
|
||||||
["ondemand\n"] = "↯",
|
["ondemand\n"] = "↯",
|
||||||
["powersave\n"] = "⌁",
|
["powersave\n"] = "⌁",
|
||||||
["userspace\n"] = "¤",
|
["userspace\n"] = "¤",
|
||||||
["performance\n"] = "⚡",
|
["performance\n"] = "⚡",
|
||||||
["conservative\n"] = "⊚"
|
["conservative\n"] = "⊚"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- {{{ CPU frequency widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local _cpufreq = helpers.pathtotable(
|
||||||
|
("/sys/devices/system/cpu/%s/cpufreq"):format(warg))
|
||||||
-- Default frequency and voltage values
|
-- Default frequency and voltage values
|
||||||
local freqv = {
|
local freqv = {
|
||||||
["mhz"] = "N/A", ["ghz"] = "N/A",
|
["mhz"] = "N/A", ["ghz"] = "N/A",
|
||||||
|
@ -43,7 +55,8 @@ local function worker(format, warg)
|
||||||
|
|
||||||
-- Get the current voltage
|
-- Get the current voltage
|
||||||
if _cpufreq.scaling_voltages then
|
if _cpufreq.scaling_voltages then
|
||||||
freqv.mv = tonumber(string.match(_cpufreq.scaling_voltages, freq.."[%s]([%d]+)"))
|
freqv.mv = tonumber(
|
||||||
|
_cpufreq.scaling_voltages:match(freq .. "[%s]([%d]+)"))
|
||||||
-- Calculate voltage from mV
|
-- Calculate voltage from mV
|
||||||
freqv.v = freqv.mv / 1000
|
freqv.v = freqv.mv / 1000
|
||||||
end
|
end
|
||||||
|
@ -52,10 +65,10 @@ local function worker(format, warg)
|
||||||
-- Get the current governor
|
-- Get the current governor
|
||||||
local governor = _cpufreq.scaling_governor
|
local governor = _cpufreq.scaling_governor
|
||||||
-- Represent the governor as a symbol
|
-- Represent the governor as a symbol
|
||||||
governor = governor_state[governor] or governor or "N/A"
|
governor = GOVERNOR_STATE[governor] or governor or "N/A"
|
||||||
|
|
||||||
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
return {freqv.mhz, freqv.ghz, freqv.mv, freqv.v, governor}
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpufreq_linux, { __call = function(_, ...) return worker(...) end })
|
return helpers.setcall(cpufreq_linux, worker)
|
||||||
|
|
|
@ -1,21 +1,33 @@
|
||||||
---------------------------------------------------
|
-- CPU information widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2017 mutlusun <mutlusun@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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
|
||||||
local string = { gmatch = string.gmatch }
|
local string = { gmatch = string.gmatch }
|
||||||
|
local helpers = require"vicious.helpers"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Cpuinf: provides speed and cache information for all available CPUs/cores
|
-- Cpuinf: provides speed and cache information for all available CPUs/cores
|
||||||
-- vicious.widgets.cpuinf
|
-- vicious.widgets.cpuinf
|
||||||
local cpuinf_linux = {}
|
local cpuinf_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- {{{ CPU Information widget type
|
-- {{{ CPU Information widget type
|
||||||
local function worker(format)
|
local function worker(format)
|
||||||
local id = nil
|
local id = nil
|
||||||
|
@ -41,4 +53,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(cpuinf_linux, { __call = function(_, ...) return worker(...) end })
|
return helpers.setcall(cpuinf_linux, worker)
|
||||||
|
|
|
@ -1,27 +1,29 @@
|
||||||
---------------------------------------------------
|
-- date and time widget type using os.date with optional time formatting
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
||||||
---------------------------------------------------
|
-- 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
|
-- {{{ Grab environment
|
||||||
local setmetatable = setmetatable
|
local os = { date = os.date, time = os.time }
|
||||||
local os = {
|
local helpers = require"vicious.helpers"
|
||||||
date = os.date,
|
|
||||||
time = os.time
|
|
||||||
}
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
return helpers.setcall({}, function (format, warg)
|
||||||
-- Date: provides access to os.date with optional time formatting
|
|
||||||
-- vicious.widgets.date
|
|
||||||
local date_all = {}
|
|
||||||
|
|
||||||
|
|
||||||
-- {{{ Date widget type
|
|
||||||
local function worker(format, warg)
|
|
||||||
return os.date(format or nil, warg and os.time()+warg or nil)
|
return os.date(format or nil, warg and os.time()+warg or nil)
|
||||||
end
|
end)
|
||||||
-- }}}
|
|
||||||
|
|
||||||
return setmetatable(date_all, { __call = function(_, ...) return worker(...) end })
|
|
||||||
|
|
|
@ -1,26 +1,35 @@
|
||||||
---------------------------------------------------
|
-- disk I/O widget type for GNU/Linux
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2011 Jörg T. <jthalheim@gmail.com>
|
||||||
-- * (c) 2011, Jörg T. <jthalheim@gmail.com>
|
-- Copyright (C) 2017 Elric Milon <whirm@gmx.com>
|
||||||
---------------------------------------------------
|
-- Copyright (C) 2017 mutlusun <mutlusun@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
|
-- {{{ Grab environment
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local io = { lines = io.lines }
|
local io = { lines = io.lines }
|
||||||
local setmetatable = setmetatable
|
local os = { time = os.time, difftime = os.difftime }
|
||||||
local string = { match = string.match }
|
|
||||||
local helpers = require("vicious.helpers")
|
|
||||||
local os = {
|
|
||||||
time = os.time,
|
|
||||||
difftime = os.difftime
|
|
||||||
}
|
|
||||||
-- }}}
|
|
||||||
|
|
||||||
|
local helpers = require"vicious.helpers"
|
||||||
|
-- }}}
|
||||||
|
|
||||||
-- Disk I/O: provides I/O statistics for requested storage devices
|
-- Disk I/O: provides I/O statistics for requested storage devices
|
||||||
-- vicious.widgets.dio
|
-- vicious.widgets.dio
|
||||||
local dio_linux = {}
|
local dio_linux = {}
|
||||||
|
|
||||||
|
|
||||||
-- Initialize function tables
|
-- Initialize function tables
|
||||||
local disk_usage = {}
|
local disk_usage = {}
|
||||||
local disk_stats = {}
|
local disk_stats = {}
|
||||||
|
@ -36,7 +45,7 @@ local function worker(format)
|
||||||
for line in io.lines("/proc/diskstats") do
|
for line in io.lines("/proc/diskstats") do
|
||||||
local device, read, write, iotime =
|
local device, read, write, iotime =
|
||||||
-- Linux kernel documentation: Documentation/iostats.txt
|
-- Linux kernel documentation: Documentation/iostats.txt
|
||||||
string.match(line, "([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+) %d+ %d+ (%d+)")
|
line:match"([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+) %d+ %d+ (%d+)"
|
||||||
disk_lines[device] = { read, write, iotime }
|
disk_lines[device] = { read, write, iotime }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +59,7 @@ local function worker(format)
|
||||||
|
|
||||||
-- Check for overflows and counter resets (> 2^32)
|
-- Check for overflows and counter resets (> 2^32)
|
||||||
if stats[1] < last_stats[1] or stats[2] < last_stats[2] then
|
if stats[1] < last_stats[1] or stats[2] < last_stats[2] then
|
||||||
last_stats[1], last_stats[2], last_stats[3] = stats[1], stats[2], stats[3]
|
for i = 1,3 do last_stats[i] = stats[i] end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Diskstats are absolute, substract our last reading
|
-- Diskstats are absolute, substract our last reading
|
||||||
|
@ -73,4 +82,4 @@ local function worker(format)
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
return setmetatable(dio_linux, { __call = function(_, ...) return worker(...) end })
|
return helpers.setcall(dio_linux, worker)
|
||||||
|
|
|
@ -1,3 +1,22 @@
|
||||||
|
-- fan speed widget type for FreeBSD
|
||||||
|
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
|
||||||
|
-- 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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -5,7 +24,6 @@ local type = type
|
||||||
local helpers = require("vicious.helpers")
|
local helpers = require("vicious.helpers")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- fanspeed: provides speed level of fans
|
-- fanspeed: provides speed level of fans
|
||||||
-- vicious.widgets.fanspeed
|
-- vicious.widgets.fanspeed
|
||||||
--
|
--
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
---------------------------------------------------
|
-- filesystem widget type
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
|
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
|
||||||
---------------------------------------------------
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
||||||
|
-- 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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
|
@ -1,7 +1,23 @@
|
||||||
---------------------------------------------------
|
-- new e-mails count and last e-mail subject on Gmail
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
||||||
---------------------------------------------------
|
-- Copyright (C) 2017 starenka <starenka0@gmail.com>
|
||||||
|
-- Copyright (C) 2018-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
|
-- {{{ Grab environment
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -12,7 +28,6 @@ local helpers = require("vicious.helpers")
|
||||||
local spawn = require("vicious.spawn")
|
local spawn = require("vicious.spawn")
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Gmail: provides count of new and subject of last e-mail on Gmail
|
-- Gmail: provides count of new and subject of last e-mail on Gmail
|
||||||
-- vicious.widgets.gmail
|
-- vicious.widgets.gmail
|
||||||
local gmail_all = {}
|
local gmail_all = {}
|
||||||
|
|
|
@ -1,7 +1,22 @@
|
||||||
---------------------------------------------------
|
-- hard drive temperatures widget type using hddtemp daemon
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
|
||||||
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
||||||
---------------------------------------------------
|
-- 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
|
-- {{{ Grab environment
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
@ -10,7 +25,6 @@ local helpers = require"vicious.helpers"
|
||||||
local spawn = require"vicious.spawn"
|
local spawn = require"vicious.spawn"
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
-- Hddtemp: provides hard drive temperatures using the hddtemp daemon
|
||||||
-- vicious.widgets.hddtemp
|
-- vicious.widgets.hddtemp
|
||||||
return helpers.setasyncall{
|
return helpers.setasyncall{
|
||||||
|
|
|
@ -1,7 +1,21 @@
|
||||||
----------------------------------------------------------------
|
-- widget type providing name-indexed temperatures from /sys/class/hwmon
|
||||||
-- Licensed under the GNU General Public License v2
|
-- Copyright (C) 2019 Alexander Koch <lynix47@gmail.com>
|
||||||
-- (C) 2019, Alexander Koch <lynix47@gmail.com>
|
-- 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/>.
|
||||||
|
|
||||||
-- environment
|
-- environment
|
||||||
local type = type
|
local type = type
|
||||||
|
|
|
@ -1,5 +1,24 @@
|
||||||
|
-- widget types initialization
|
||||||
|
-- Copyright (C) 2010 Adrian C. (anrxc) <anrxc@sysphere.org>
|
||||||
|
-- Copyright (C) 2011,2012 Jörg Thalheim <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/>.
|
||||||
|
|
||||||
|
local setmetatable = setmetatable
|
||||||
local wrequire = require("vicious.helpers").wrequire
|
local wrequire = require("vicious.helpers").wrequire
|
||||||
widgets = { _NAME = "vicious.widgets" }
|
|
||||||
|
|
||||||
return setmetatable(widgets, {__index = wrequire})
|
return setmetatable({ _NAME = "vicious.widgets" }, { __index = wrequire })
|
||||||
|
|
Loading…
Reference in New Issue