aboutsummaryrefslogtreecommitdiff
path: root/pkg.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-02-04 20:45:11 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-02-04 20:45:11 +0100
commit3095ffbcd5537f43572e87413e2187e8cee057c0 (patch)
treebdf64113ae266f5d3ea6d19b3314caa4be9412b2 /pkg.lua
parent91925e601d9809bf17e6a79cfa4cfad9937ed29a (diff)
downloadvicious-legacy-3095ffbcd5537f43572e87413e2187e8cee057c0.tar.xz
pkg: added apt and yum to pkg managers table
This widget type now takes the distribution name as an argument; Arch, Arch S, Debian and Fedora examples are now in the package manager table. Feedback from yum users is needed.
Diffstat (limited to 'pkg.lua')
-rw-r--r--pkg.lua19
1 files changed, 12 insertions, 7 deletions
diff --git a/pkg.lua b/pkg.lua
index 917b893..b0cf501 100644
--- a/pkg.lua
+++ b/pkg.lua
@@ -4,8 +4,8 @@
---------------------------------------------------
-- {{{ Grab environment
-local tonumber = tonumber
local io = { popen = io.popen }
+local math = { max = math.max }
local setmetatable = setmetatable
-- }}}
@@ -15,21 +15,26 @@ module("vicious.pkg")
-- {{{ Packages widget type
-local function worker(format)
+local function worker(format, dist)
-- Initialise counters
local updates = 0
+ local manager = {
+ ["Arch"] = { cmd = "pacman -Qu" },
+ ["Arch S"] = { cmd = "pacman -Sup", sub = 2 },
+ ["Debian"] = { cmd = "apt-show-versions -u -b" },
+ ["Fedora"] = { cmd = "yum list updates", sub = 3 }
+ }
- -- Check if updates are available on Arch
- local f = io.popen("pacman -Qu")
- --- Exclude IgnorePkg and count deps
- ---local f = io.popen("pacman -Sup")
+ -- Check if updates are available
+ local pkg = manager[dist]
+ local f = io.popen(pkg.cmd)
for line in f:lines() do
updates = updates + 1
end
f:close()
- return {updates}
+ return {pkg.sub and math.max(updates-pkg.sub, 0) or updates}
end
-- }}}