From 3095ffbcd5537f43572e87413e2187e8cee057c0 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Thu, 4 Feb 2010 20:45:11 +0100 Subject: 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. --- pkg.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'pkg.lua') 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 -- }}} -- cgit v1.2.3