diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-02-04 20:45:11 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2010-02-04 20:45:11 +0100 |
commit | 3095ffbcd5537f43572e87413e2187e8cee057c0 (patch) | |
tree | bdf64113ae266f5d3ea6d19b3314caa4be9412b2 | |
parent | 91925e601d9809bf17e6a79cfa4cfad9937ed29a (diff) | |
download | vicious-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.
-rw-r--r-- | README | 5 | ||||
-rw-r--r-- | pkg.lua | 19 |
2 files changed, 15 insertions, 9 deletions
@@ -247,8 +247,9 @@ vicious.widgets.org of tasks for today, 3rd as count of tasks for the next 3 days and 4th as count of tasks to do in the week -vicious.widgets.pacman - - provides number of pending updates on Arch Linux +vicious.widgets.pkg + - provides number of pending updates on GNU/Linux + - takes the distribution name as an argument, i.e. "Arch" - returns 1st value as the count of available updates vicious.widgets.mpd @@ -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 -- }}} |