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
|
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
|
|
|
|
local pkg = {}
|
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
|
2010-03-14 03:37:40 +01:00
|
|
|
local function worker(format, warg)
|
|
|
|
if not warg then return end
|
|
|
|
|
2010-04-02 01:08:12 +02:00
|
|
|
-- Initialize counters
|
2009-09-14 17:25:23 +02:00
|
|
|
local updates = 0
|
2010-02-04 20:45:11 +01:00
|
|
|
local manager = {
|
|
|
|
["Arch"] = { cmd = "pacman -Qu" },
|
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 },
|
2010-08-22 14:46:05 +02: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
|
2012-06-15 18:07:05 +02:00
|
|
|
local _pkg = manager[warg]
|
|
|
|
local f = io.popen(_pkg.cmd)
|
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
|
|
|
|
|
|
|
for line in f:lines() do
|
2009-09-14 17:25:23 +02:00
|
|
|
updates = updates + 1
|
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
|
|
|
|
f:close()
|
|
|
|
|
2012-06-15 18:07:05 +02:00
|
|
|
return {_pkg.sub and math.max(updates-_pkg.sub, 0) or updates}
|
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
|
|
|
|
2012-06-15 18:07:05 +02:00
|
|
|
return setmetatable(pkg, { __call = function(_, ...) return worker(...) end })
|