You are not logged in.

#1 2010-06-08 10:37:05

samuele.mattiuzzo
Member
From: Treviso, IT
Registered: 2009-10-12
Posts: 307
Website

[SOLVED]Awesome WM and vicious.widgets.pkg issues

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

#2 2010-06-08 10:43:32

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: [SOLVED]Awesome WM and vicious.widgets.pkg issues

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

#3 2010-06-08 10:44:41

samuele.mattiuzzo
Member
From: Treviso, IT
Registered: 2009-10-12
Posts: 307
Website

Re: [SOLVED]Awesome WM and vicious.widgets.pkg issues

solved it by adding "Arch" after 1800 smile

thanks to all who helped smile

Offline

#4 2010-06-08 13:05:12

samuele.mattiuzzo
Member
From: Treviso, IT
Registered: 2009-10-12
Posts: 307
Website

Re: [SOLVED]Awesome WM and vicious.widgets.pkg issues

bumping up the thread again sad

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

#5 2010-06-08 15:12:09

anrxc
Member
From: Croatia
Registered: 2008-03-22
Posts: 834
Website

Re: [SOLVED]Awesome WM and vicious.widgets.pkg issues

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

#6 2010-06-08 15:16:38

samuele.mattiuzzo
Member
From: Treviso, IT
Registered: 2009-10-12
Posts: 307
Website

Re: [SOLVED]Awesome WM and vicious.widgets.pkg issues

anrxc wrote:

I already told you. There is no wc in the original code, there is no yaourt. This is not my code.

hehe sorry tongue 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 smile

thanks smile

and nice work big_smile

Offline

Board footer

Powered by FluxBB