Correct the copyright headers of the rest widget type

This commit is contained in:
Nguyễn Gia Phong 2019-09-14 10:33:40 +07:00
parent f54f1a7d8e
commit bea390a75e
23 changed files with 509 additions and 202 deletions

View File

@ -32,7 +32,7 @@ Fixed:
- [pkg] Use more updated front-ends for Debian/Ubuntu (apt) and Fedora (dnf)
- [os] Splitted os_all into os_linux and os_bsd (and refactored to async)
- Tweak `.luacheckrc` to suit functional style and soft-limit text width to 80
- Update copyright headers for libraries
- Update copyright headers for libraries and official widget types
Removed:

View File

@ -1,22 +1,32 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- widget type providing the subject of last e-mail in a mbox file
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- 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 = { open = io.open }
local setmetatable = setmetatable
local string = { gfind = string.gfind }
local helpers = require("vicious.helpers")
-- }}}
-- Mbox: provides the subject of last e-mail in a mbox file
-- vicious.widgets.mbox
local mbox_all = {}
-- Initialize variables
local subject = "N/A"
@ -24,18 +34,15 @@ local subject = "N/A"
local function worker(format, warg)
if not warg then return end
-- mbox could be huge, get a 30kb chunk from EOF
if type(warg) ~= "table" then _mbox = warg end
-- * attachment could be much bigger than 30kb
local f = io.open(_mbox or warg[1])
local f = io.open(type(warg) == "table" and warg[1] or warg)
f:seek("end", -30720)
-- mbox could be huge, get a 30kb chunk from EOF
-- * attachment could be much bigger than 30kb
local txt = f:read("*all")
f:close()
-- Find all Subject lines
for i in string.gfind(txt, "Subject: ([^\n]*)") do
subject = i
end
for i in txt:gmatch"Subject: ([^\n]*)" do subject = i end
-- Check if we should scroll, or maybe truncate
if type(warg) == "table" then
@ -46,8 +53,8 @@ local function worker(format, warg)
end
end
return {subject}
return { subject }
end
-- }}}
return setmetatable(mbox_all, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(mbox_all, worker)

View File

@ -1,20 +1,30 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- widget type providing the count of total, old and new messages in mbox files
-- Copyright (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
local io = { open = io.open }
local setmetatable = setmetatable
local string = { find = string.find }
local helpers = require"vicious.helpers"
-- }}}
-- Mboxc: provides the count of total, old and new messages in mbox files
-- vicious.widgets.mboxc
local mboxc_all = {}
-- {{{ Mbox count widget type
local function worker(format, warg)
if not warg then return end
@ -34,15 +44,15 @@ local function worker(format, warg)
-- Find all messages
-- * http://www.jwz.org/doc/content-length.html
local _, from = string.find(lines, "^From[%s]")
local _, from = lines:find"^From[%s]"
if from ~= nil then count.total = count.total + 1 end
-- Read messages have the Status header
local _, status = string.find(lines, "^Status:[%s]RO$")
local _, status = lines:find"^Status:[%s]RO$"
if status ~= nil then count.old = count.old + 1 end
-- Skip the folder internal data
local _, int = string.find(lines, "^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA")
local _, int = lines:find"^Subject:[%s].*FOLDER[%s]INTERNAL[%s]DATA"
if int ~= nil then count.total = count.total - 1 end
end
f:close()
@ -55,4 +65,4 @@ local function worker(format, warg)
end
-- }}}
return setmetatable(mboxc_all, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(mboxc_all, worker)

View File

@ -1,8 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) Maildir Biff Widget, Fredrik Ax
---------------------------------------------------
-- widget type providing number of new and unread Maildir messages
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2010 Fredrik Ax
-- 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
local type = type
@ -11,12 +26,9 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Mdir: provides the number of new and unread messages in Maildir structures/dirs
-- vicious.widgets.mdir
local mdir_all = {}
-- {{{ Maildir widget type
function mdir_all.async(format, warg, callback)
if type(warg) ~= "table" then return callback{} end

View File

@ -1,3 +1,23 @@
-- RAM and swap usage widget type for FreeBSD
-- Copyright (C) 2017-2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Andreas Geisenhainer <psycorama@datenhalde.de>
-- 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 tonumber = tonumber
local math = { floor = math.floor }

View File

@ -1,22 +1,35 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- RAM and swap usage widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Jay Kamat <jaygkamat@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 = { lines = io.lines }
local setmetatable = setmetatable
local math = { floor = math.floor }
local string = { gmatch = string.gmatch }
local helpers = require"vicious.helpers"
-- }}}
-- Mem: provides RAM and Swap usage statistics
-- vicious.widgets.mem
local mem_linux = {}
-- {{{ Memory widget type
local function worker(format)
local _mem = { buf = {}, swp = {} }
@ -50,4 +63,4 @@ local function worker(format)
end
-- }}}
return setmetatable(mem_linux, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(mem_linux, worker)

View File

@ -1,7 +1,25 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- Music Player Daemon widget type
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017,2019 mutlusun <mutlusun@github.com>
-- Copyright (C) 2018 Jörg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2018-2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Juan Carlos Menonita <JuanKman94@users.noreply.github.com>
-- Copyright (C) 2019 Lorenzo Gaggini <lg@lgaggini.net>
--
-- 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
@ -12,7 +30,6 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Mpd: provides Music Player Daemon information
-- vicious.widgets.mpd
local mpd_all = {}

View File

@ -1,3 +1,22 @@
-- network status and 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
local tonumber = tonumber
local os = { time = os.time }

View File

@ -1,24 +1,35 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- network status and usage widget type for GNU/Linux
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (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
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 state and usage statistics of all network interfaces
-- vicious.widgets.net
local net_linux = {}
-- Initialize function tables
local nets = {}
-- Variable definitions
@ -77,4 +88,4 @@ local function worker(format)
end
-- }}}
return setmetatable(net_linux, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(net_linux, worker)

View File

@ -1,62 +1,71 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) org-awesome, Damien Leone
---------------------------------------------------
-- widget type providing agenda from Emacs org-mode
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2010 org-awesome, Damien Leone
-- 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
local io = { lines = io.lines }
local setmetatable = setmetatable
local string = { find = string.find }
local os = {
time = os.time,
date = os.date
}
local os = { time = os.time, date = os.date }
local helpers = require"vicious.helpers"
-- }}}
-- Org: provides agenda statistics for Emacs org-mode
-- vicious.widgets.org
local org_all = {}
-- {{{ OrgMode widget type
local function worker(format, warg)
if not warg then return end
-- Compute delays
local today = os.time{ year=os.date("%Y"), month=os.date("%m"), day=os.date("%d") }
local soon = today + 24 * 3600 * 3 -- 3 days ahead is close
local future = today + 24 * 3600 * 7 -- 7 days ahead is maximum
local today = os.time{ year = os.date("%Y"), month = os.date("%m"),
day = os.date("%d") }
local soon = today + 24*3600*3 -- 3 days ahead is close
local future = today + 24*3600*7 -- 7 days ahead is maximum
-- Initialize counters
local count = { past = 0, today = 0, soon = 0, future = 0 }
-- Get data from agenda files
for i=1, #warg do
for line in io.lines(warg[i]) do
local scheduled = string.find(line, "SCHEDULED:")
local closed = string.find(line, "CLOSED:")
local deadline = string.find(line, "DEADLINE:")
for i = 1,#warg do
for line in io.lines(warg[i]) do
local scheduled = line:find"SCHEDULED:"
local deadline = line:find"DEADLINE:"
local closed = line:find"CLOSED:"
local b, _, y, m, d = line:find"(%d%d%d%d)-(%d%d)-(%d%d)"
if (scheduled and not closed) or (deadline and not closed) then
local b, e, y, m, d = string.find(line, "(%d%d%d%d)-(%d%d)-(%d%d)")
if b then
local t = os.time{ year = y, month = m, day = d }
if t < today then count.past = count.past + 1
elseif t == today then count.today = count.today + 1
elseif t <= soon then count.soon = count.soon + 1
elseif t <= future then count.future = count.future + 1
if (scheduled or deadline) and not closed and b then
local t = os.time{ year = y, month = m, day = d }
if t < today then
count.past = count.past + 1
elseif t == today then
count.today = count.today + 1
elseif t <= soon then
count.soon = count.soon + 1
elseif t <= future then
count.future = count.future + 1
end
end
end
end
end
end
end
return {count.past, count.today, count.soon, count.future}
return { count.past, count.today, count.soon, count.future }
end
-- }}}
return setmetatable(org_all, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(org_all, worker)

View File

@ -1,7 +1,20 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- operating system widget type for *BSD
-- Copyright (C) 2019 mutlusun <mutlusun@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 los = { getenv = os.getenv }
@ -10,12 +23,10 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- OS: provides operating system information
-- vicious.widgets.os
local os_bsd = {}
-- {{{ Operating system widget type
local function parse(stdout, stderr, exitreason, exitcode)
local system = {

View File

@ -1,25 +1,37 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- operating system widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 mutlusun <mutlusun@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 math = { ceil = math.ceil }
local los = { getenv = os.getenv }
local setmetatable = setmetatable
local string = { gsub = string.gsub }
local helpers = require"vicious.helpers"
-- }}}
-- OS: provides operating system information
-- vicious.widgets.os
local os_linux = {}
-- {{{ Operating system widget type
local function worker(format)
local system = {
@ -57,5 +69,4 @@ local function worker(format)
end
-- }}}
return setmetatable(os_linux,
{ __call = function(_, ...) return worker(...) end })
return helpers.setcall(os_linux, worker)

View File

@ -1,14 +1,30 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- widget type providing number of pending updates
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Joerg Thalheim <joerg@thalheim.io>
-- Copyright (C) 2017 getzze <getzze@gmail.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
local spawn = require("vicious.spawn")
local helpers = require("vicious.helpers")
-- }}}
-- Pkg: provides number of pending updates on UNIX systems
-- vicious.widgets.pkg
local pkg_all = {}

View File

@ -1,25 +1,38 @@
-----------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Hagen Schink <troja84@googlemail.com>
-----------------------------------------------------
-- widget type providing RAID array information on GNU/Linux
-- Copyright (C) 2010 Hagen Schink <troja84@googlemail.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
local io = { open = io.open }
local setmetatable = setmetatable
local string = {
len = string.len,
sub = string.sub,
match = string.match,
gmatch = string.gmatch
}
-- }}}
local helpers = require"vicious.helpers"
-- }}}
-- Raid: provides state information for a requested RAID array
-- vicious.widgets.raid
local raid_linux = {}
-- Initialize function tables
local mddev = {}
@ -38,7 +51,7 @@ local function worker(format, warg)
if mddev[warg]["found"] then
local updev = string.match(line, "%[[_U]+%]")
for i in string.gmatch(updev, "U") do
for _ in string.gmatch(updev, "U") do
mddev[warg]["active"] = mddev[warg]["active"] + 1
end
@ -46,7 +59,7 @@ local function worker(format, warg)
elseif string.sub(line, 1, string.len(warg)) == warg then
mddev[warg]["found"] = true
for i in string.gmatch(line, "%[[%d]%]") do
for _ in string.gmatch(line, "%[[%d]%]") do
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
end
end
@ -57,4 +70,4 @@ local function worker(format, warg)
end
-- }}}
return setmetatable(raid_linux, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(raid_linux, worker)

View File

@ -1,3 +1,22 @@
-- temperature 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
local string = { match = string.match }
local type = type
@ -5,7 +24,6 @@ local type = type
local helpers = require("vicious.helpers")
-- }}}
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
-- vicious.widgets.thermal
local thermal_freebsd = {}

View File

@ -1,23 +1,34 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- temperature widget type for GNU/Linux
-- Copyright (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
local type = type
local tonumber = tonumber
local setmetatable = setmetatable
local string = { match = string.match }
local helpers = require("vicious.helpers")
local math = { floor = math.floor }
local helpers = require("vicious.helpers")
-- }}}
-- Thermal: provides temperature levels of ACPI and coretemp thermal zones
-- vicious.widgets.thermal
local thermal_linux = {}
-- {{{ Thermal widget type
local function worker(format, warg)
if not warg then return end
@ -46,4 +57,4 @@ local function worker(format, warg)
end
-- }}}
return setmetatable(thermal_linux, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(thermal_linux, worker)

View File

@ -1,3 +1,22 @@
-- uptime 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
local tonumber = tonumber
local math = { floor = math.floor }
@ -6,12 +25,10 @@ local os = { time = os.time }
local helpers = require("vicious.helpers")
-- }}}
-- Uptime: provides system uptime and load information
-- vicious.widgets.uptime
local uptime_freebsd = {}
-- {{{ Uptime widget type
function uptime_freebsd.async(format, warg, callback)
helpers.sysctl_async(

View File

@ -1,22 +1,33 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
-- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
---------------------------------------------------
-- uptime widget type for GNU/Linux
-- Copyright (C) 2009 Lucas de Vries <lucas@glacicle.com>
-- Copyright (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
local setmetatable = setmetatable
local math = { floor = math.floor }
local string = { match = string.match }
local helpers = require("vicious.helpers")
-- }}}
-- Uptime: provides system uptime and load information
-- vicious.widgets.uptime
local uptime_linux = {}
-- {{{ Uptime widget type
local function worker(format)
local proc = helpers.pathtotable("/proc")
@ -28,9 +39,9 @@ local function worker(format)
local up_m = math.floor(((up_t % (3600 * 24)) % 3600) / 60)
local l1, l5, l15 = -- Get load averages for past 1, 5 and 15 minutes
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
string.match(proc.loadavg, "([%d%.]+)[%s]([%d%.]+)[%s]([%d%.]+)")
return {up_d, up_h, up_m, l1, l5, l15}
end
-- }}}
return setmetatable(uptime_linux, { __call = function(_, ...) return worker(...) end })
return helpers.setcall(uptime_linux, worker)

View File

@ -1,3 +1,22 @@
-- volume 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
local tonumber = tonumber
local string = { match = string.match }
@ -5,12 +24,10 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Volume: provides volume levels and state of requested mixer
-- vicious.widgets.volume_freebsd
local volume_freebsd = {}
-- {{{ Volume widget type
local STATE = { on = '🔉', off = '🔈' }

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- volume widget type for GNU/Linux
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 Brandon Hartshorn <brandonhartshorn@gmail.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
local type = type
@ -13,7 +29,6 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Volume: provides volume levels and state of requested ALSA mixers
-- vicious.widgets.volume
local volume_linux = {}

View File

@ -1,19 +1,34 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- weather widget type fetching from from US NOAA
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Arthur Axel 'fREW' Schmidt <git@frew.co>
-- 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 tonumber = tonumber
local math = { ceil = math.ceil }
local os = { date = os.date, difftime = os.difftime, time = os.time }
local string = { match = string.match }
local string = { format = string.format }
local spawn = require"vicious.spawn"
local helpers = require"vicious.helpers"
-- }}}
-- Weather: provides weather information for a requested station
-- vicious.widgets.weather
local weather_all = {}
@ -27,7 +42,6 @@ local function get_timezone_offset()
return os.difftime(os.time(localdate), os.time(utcdate))
end
-- {{{ Weather widget type
local function parse(stdout, stderr, exitreason, exitcode)
-- Initialize function tables
@ -51,55 +65,59 @@ local function parse(stdout, stderr, exitreason, exitcode)
if stdout == '' then return _weather end
_weather["{city}"] = -- City and/or area
string.match(stdout, "^(.+)%,.*%([%u]+%)") or _weather["{city}"]
stdout:match"^(.+)%,.*%([%u]+%)"
or _weather["{city}"]
_weather["{wind}"] = -- Wind direction and degrees if available
string.match(stdout, "Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$") or _weather["{wind}"]
stdout:match"Wind:[%s][%a]+[%s][%a]+[%s](.+)[%s]at.+$"
or _weather["{wind}"]
_weather["{windmph}"] = -- Wind speed in MPH if available
string.match(stdout, "Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH") or _weather["{windmph}"]
stdout:match"Wind:[%s].+[%s]at[%s]([%d]+)[%s]MPH"
or _weather["{windmph}"]
_weather["{sky}"] = -- Sky conditions if available
string.match(stdout, "Sky[%s]conditions:[%s](.-)[%c]") or _weather["{sky}"]
stdout:match"Sky[%s]conditions:[%s](.-)[%c]"
or _weather["{sky}"]
_weather["{weather}"] = -- Weather conditions if available
string.match(stdout, "Weather:[%s](.-)[%c]") or _weather["{weather}"]
stdout:match"Weather:[%s](.-)[%c]"
or _weather["{weather}"]
_weather["{tempf}"] = -- Temperature in fahrenheit
string.match(stdout, "Temperature:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{tempf}"]
stdout:match"Temperature:[%s]([%-]?[%d%.]+).*[%c]"
or _weather["{tempf}"]
_weather["{dewf}"] = -- Dew Point in fahrenheit
string.match(stdout, "Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]") or _weather["{dewf}"]
stdout:match"Dew[%s]Point:[%s]([%-]?[%d%.]+).*[%c]"
or _weather["{dewf}"]
_weather["{humid}"] = -- Relative humidity in percent
string.match(stdout, "Relative[%s]Humidity:[%s]([%d]+)%%") or _weather["{humid}"]
stdout:match"Relative[%s]Humidity:[%s]([%d]+)%%"
or _weather["{humid}"]
_weather["{press}"] = -- Pressure in hPa
string.match(stdout, "Pressure[%s].+%((.+)[%s]hPa%)") or _weather["{press}"]
stdout:match"Pressure[%s].+%((.+)[%s]hPa%)"
or _weather["{press}"]
local year, month, day, hour, min =
string.match(stdout, "(%d%d%d%d).(%d%d).(%d%d) (%d%d)(%d%d) UTC")
stdout:match"(%d%d%d%d).(%d%d).(%d%d) (%d%d)(%d%d) UTC"
if year ~= nil then
local utctable = {
year = year,
month = month,
day = day,
hour = hour,
min = min,
}
_weather["{when}"] = os.time(utctable) + get_timezone_offset()
local utctable = { year = year, month = month, day = day,
hour = hour, min = min }
_weather["{when}"] = os.time(utctable) + get_timezone_offset()
end
-- Wind speed in km/h if MPH was available
if _weather["{windmph}"] ~= "N/A" then
_weather["{windmph}"] = tonumber(_weather["{windmph}"])
_weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6)
_weather["{windmph}"] = tonumber(_weather["{windmph}"])
_weather["{windkmh}"] = math.ceil(_weather["{windmph}"] * 1.6)
end -- Temperature in °C if °F was available
if _weather["{tempf}"] ~= "N/A" then
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
_weather["{tempf}"] = tonumber(_weather["{tempf}"])
_weather["{tempc}"] = math.ceil((_weather["{tempf}"] - 32) * 5/9)
end -- Dew Point in °C if °F was available
if _weather["{dewf}"] ~= "N/A" then
_weather["{dewf}"] = tonumber(_weather["{dewf}"])
_weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
_weather["{dewf}"] = tonumber(_weather["{dewf}"])
_weather["{dewc}"] = math.ceil((_weather["{dewf}"] - 32) * 5/9)
end -- Capitalize some stats so they don't look so out of place
if _weather["{sky}"] ~= "N/A" then
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])
_weather["{sky}"] = helpers.capitalize(_weather["{sky}"])
end
if _weather["{weather}"] ~= "N/A" then
_weather["{weather}"] = helpers.capitalize(_weather["{weather}"])
_weather["{weather}"] = helpers.capitalize(_weather["{weather}"])
end
return _weather
@ -110,7 +128,9 @@ function weather_all.async(format, warg, callback)
-- Get weather forceast by the station ICAO code, from:
-- * US National Oceanic and Atmospheric Administration
local url = ("https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT"):format(warg)
local url = string.format(
"https://tgftp.nws.noaa.gov/data/observations/metar/decoded/%s.TXT",
warg)
spawn.easy_async("curl -fs " .. url,
function (...) callback(parse(...)) end)
end

View File

@ -1,7 +1,22 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- Wi-Fi widget type for GNU/Linux using iwconfig
-- Copyright (C) 2010 Adrian C. <anrxc@sysphere.org>
-- Copyright (C) 2017 mutlusun <mutlusun@github.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
local type = type
@ -12,7 +27,6 @@ local helpers = require"vicious.helpers"
local spawn = require"vicious.spawn"
-- }}}
-- Wifi: provides wireless information for a requested interface using iwconfig
-- vicious.widgets.wifi
local wifi_linux = {}

View File

@ -1,7 +1,23 @@
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2016, Marius M. <mellich@gmx.net>
---------------------------------------------------
-- Wi-Fi widget type for GNU/Linux using iw
-- Copyright (C) 2016 Marius M. <mellich@gmx.net>
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
-- Copyright (C) 2019 Nguyễn Gia Phong <vn.mcsinyx@gmail.com>
-- Copyright (C) 2019 Xaver Hellauer <xaver@hellauer.bayern>
--
-- 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
@ -11,7 +27,6 @@ local helpers = require("vicious.helpers")
local spawn = require("vicious.spawn")
-- }}}
-- Wifiiw: provides wireless information for a requested interface
-- using iw instead of deprecated iwconfig
-- vicious.widgets.wifiiw