You are not logged in.
Hi all, on my awesome wm i want to have a widget telling me how many pacman / yaourt upgrades are available. I tried with vicious library, where i have a "pkg.lua" file
this is my rc.lua
...
-- Pacman Widget
pacwidget = widget({type="textbox"})
vicious.register(pacwidget, vicious.widgets.pkg, "<span color='black'><b> UPDATES: </b></span> $1 ", 1801)
..
but when i try to use it, have an error saying i'm attempting to call a NIL value on row 30 of pkg.lua file, which looks like this:
---------------------------------------------------
-- Licensed under the GNU General Public License v2
-- * (c) 2010, Adrian C. <anrxc@sysphere.org>
---------------------------------------------------
-- {{{ Grab environment
local io = { popen = io.popen }
local math = { max = math.max }
local setmetatable = setmetatable
-- }}}
-- Pkg: provides number of pending updates on GNU/Linux
module("vicious.pkg")
-- {{{ Packages widget type
local function worker(format, dist)
-- Initialise counters
local updates = 0
local manager = {
["Arch"] = { cmd = "pacman -Qu | wc -l" },
["Arch S"] = { cmd = "yes | pacman -Sup", sub = 2 },
["Debian"] = { cmd = "apt-show-versions -u -b" },
["Fedora"] = { cmd = "yum list updates", sub = 3 }
}
-- 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 {pkg.sub and math.max(updates-pkg.sub, 0) or updates}
end
-- }}}
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
The line that gives me error is this one:
local f = io.popen(pkg.cmd)
anyone can tell me what's wrong? thanks!
Last edited by samuele.mattiuzzo (2010-06-08 10:45:01)
Offline
anyone can tell me what's wrong?
No widget argument. Broken Arch command, there is no wc in the original code.
You need to install an RTFM interface.
Offline
solved it by adding "Arch" after 1800
thanks to all who helped
Offline
bumping up the thread again
the pkg.lua keeps telling me i have an update for my system...
i noticed that it counts lines into the command yaourt -Qu | wc -l then puts it in a local f
after all this, it counts lines in this "f" variable... but the output of yaourt -Qu | wc -l is already an integer (i guess number of packages availables, counted by number of lines right?) so i always get a "1" as output...
(i'm sorry for my baaad english for this post) how can i fix this? what's exactly supposed to do the pkg.lua vicious widget?
Offline
I already told you. There is no wc in the original code, there is no yaourt. This is not my code.
You need to install an RTFM interface.
Offline
I already told you. There is no wc in the original code, there is no yaourt. This is not my code.
hehe sorry i actually don't know why it had the wc, i never changed that, nor i changed pacman with yaourt (just used to yaourt, so when i wrote the post i used yaourt)
anyway, it seems fixed now, removing the wc command
thanks
and nice work
Offline