2009-09-29 22:33:19 +02:00
|
|
|
---------------------------------------------------
|
|
|
|
-- Licensed under the GNU General Public License v2
|
2010-01-02 21:21:54 +01:00
|
|
|
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
|
2009-09-29 22:33:19 +02:00
|
|
|
---------------------------------------------------
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
-- {{{ Grab environment
|
|
|
|
local io = { popen = io.popen }
|
2010-02-04 20:45:11 +01:00
|
|
|
local math = { max = math.max }
|
2009-08-01 23:11:41 +02:00
|
|
|
local setmetatable = setmetatable
|
2017-07-13 22:42:26 +02:00
|
|
|
local spawn = require("awful.spawn")
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
|
2010-08-29 13:53:26 +02:00
|
|
|
-- Pkg: provides number of pending updates on UNIX systems
|
2012-06-15 18:07:05 +02:00
|
|
|
-- vicious.widgets.pkg
|
2017-01-25 17:54:55 +01:00
|
|
|
local pkg_all = {}
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
|
|
|
|
2010-02-04 18:36:27 +01:00
|
|
|
-- {{{ Packages widget type
|
2017-07-13 22:42:26 +02:00
|
|
|
function pkg_all.async(warg, callback)
|
2010-03-14 03:37:40 +01:00
|
|
|
if not warg then return end
|
|
|
|
|
2010-04-02 01:08:12 +02:00
|
|
|
-- Initialize counters
|
2010-02-04 20:45:11 +01:00
|
|
|
local manager = {
|
2013-11-02 18:14:07 +01:00
|
|
|
["Arch"] = { cmd = "pacman -Qu" },
|
|
|
|
["Arch C"] = { cmd = "checkupdates" },
|
2012-05-09 03:13:13 +02:00
|
|
|
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 1 },
|
2010-02-04 20:45:11 +01:00
|
|
|
["Debian"] = { cmd = "apt-show-versions -u -b" },
|
2010-03-19 00:51:57 +01:00
|
|
|
["Ubuntu"] = { cmd = "aptitude search '~U'" },
|
2010-04-21 02:08:04 +02:00
|
|
|
["Fedora"] = { cmd = "yum list updates", sub = 3 },
|
2017-01-25 17:54:55 +01:00
|
|
|
["FreeBSD"] ={ cmd = "pkg version -I -l '<'" },
|
2010-04-21 02:08:04 +02:00
|
|
|
["Mandriva"]={ cmd = "urpmq --auto-select" }
|
2010-02-04 20:45:11 +01:00
|
|
|
}
|
2009-09-14 17:25:23 +02:00
|
|
|
|
2010-02-04 20:45:11 +01:00
|
|
|
-- Check if updates are available
|
2017-07-13 22:42:26 +02:00
|
|
|
local function parse(str, skiprows)
|
|
|
|
local size, lines, first = 0, "", skiprows or 0
|
|
|
|
for line in str:gmatch("[^\r\n]+") do
|
|
|
|
if size >= first then
|
|
|
|
lines = lines .. (size == first and "" or "\n") .. line
|
|
|
|
end
|
|
|
|
size = size + 1
|
|
|
|
end
|
|
|
|
size = math.max(size-first, 0)
|
|
|
|
return {size, lines}
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Select command
|
2012-06-15 18:07:05 +02:00
|
|
|
local _pkg = manager[warg]
|
2017-07-13 22:42:26 +02:00
|
|
|
spawn.easy_async(_pkg.cmd, function(stdout) callback(parse(stdout, _pkg.sub)) end)
|
|
|
|
end
|
|
|
|
-- }}}
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
2017-07-13 22:42:26 +02:00
|
|
|
-- {{{ Packages widget type
|
|
|
|
local function worker(format, warg)
|
|
|
|
local ret = nil
|
|
|
|
|
|
|
|
pkg_all.async(warg, function(data) ret = data end)
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
|
2017-07-13 22:42:26 +02:00
|
|
|
while ret==nil do end
|
|
|
|
return ret
|
Import of vicious source tree.
Vicious is a modular widget library for 'awesome' window manager,
derived from the 'Wicked' widget library.
Summary of changes:
* Original wicked code modularized
* Widgets ported from Wicked:
- CPU, MEM, FS, NET, Date, Uptime, MPD
* CPU widget rewritten, uses pattern matching
* MEM widget rewritten, uses pattern matching
- Swap widget merged with MEM widget type
* FS widget rewritten, uses pattern matching
- Also fixed padding in the process
* NET widget rewritten, uses pattern matching
* MPD widget rewritten, a bit more versatile
* Removed deprecated helper functions
* Widgets written for Vicious:
- Thermal, Battery, Mbox, OrgMode, Volume, Entropy,
Disk I/O, System Load, Wireless, Pacman, Maildir
2009-07-29 17:59:32 +02:00
|
|
|
end
|
|
|
|
-- }}}
|
2009-08-01 23:11:41 +02:00
|
|
|
|
2017-07-13 22:42:26 +02:00
|
|
|
|
2017-01-25 17:54:55 +01:00
|
|
|
return setmetatable(pkg_all, { __call = function(_, ...) return worker(...) end })
|