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.
This commit is contained in:
parent
91925e601d
commit
3095ffbcd5
5
README
5
README
|
@ -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
|
||||
|
|
19
pkg.lua
19
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
|
||||
-- }}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue