You are not logged in.

#1 2014-10-16 02:17:29

n1x4
Member
From: Chernobyl
Registered: 2012-02-17
Posts: 149
Website

[SOLVED]Awesomewm vicious wifi widget

Didn't know if I should ask here or in Programming & Scripting but seeing as how this is more or less related to my WM I'll just post here, move if need be.

I'd like to get my local ip in my taskbar but cannot seem to find anything on it using google or search here. Which brings me to my second albeit probably more important question. How can I find out what widget library contains what and how to use it? For example

vicious.register(batterywidget, vicious.widgets.bat, " $2% ", 60, "BAT0")

where can I find the syntax/usage of the vicious bat lib(?)? Like how in the hell, without existing scripts on github would one know how to write that properly? Know what it outputs?

All my current widgets are just pieces of others that i've glued together. I've not actually gotten to write anything personally because I simply do not know where to look for what contains what and how to access said what via rc.lua.

Back to the first question. Current code is:

wifiwidget = widget({ type = "textbox" })
    vicious.register(wifiwidget, vicious.widgets.wifi,
    function (widget, args)
        if args["{link}"] == 0 then
            return " " .. colbred .. "n/a" .. coldef .. " "
        else
            return "" .. colbgre .. string.format(" %s ", args["{ssid}"]) .. coldef .. " "
        end
    end, refresh_delay, "wlan0" )

which displays APs ssid in green and n/a in red when not connected but would like to replace the ssid with local ip. (Used some other users code on the forum can't recall to whom it was). Can the wifi lib(or w/e it's called) even do that? Or is it the vicious net lib(?)? I dunno because I have no clue where any docs are on each "lib" within vicious.

Any help would be greatly appreciated and apologies if it's not clear to what I mean. Still trying to learn a little lua so if confused ask and i'll TRY to explain it better.

Last edited by n1x4 (2014-10-16 05:23:28)


||github||

Offline

#2 2014-10-16 04:18:03

naelstrof
Member
Registered: 2011-10-21
Posts: 15

Re: [SOLVED]Awesomewm vicious wifi widget

Looking at the libs myself it doesn't seem like any of them supply an IP. However you could probably easily edit vicious/wifi.lua to include an ip variable.
iwconfig does print out IP information, but it's not being read by the vicious wifi lib.

https://github.com/Mic92/vicious/blob/m … s/wifi.lua

On line 44-ish I'd add a

"["{ip}"] = "localhost"

,
then on line 74-ish I'd add a regular expression to parse the ip from the output of iwconfig.
It would look something like this:

winfo["{ip}"] = helpers.escape(string.match(iw, 'inet[=:]"(.-)"') or winfo["{ip}"])

, but I know jack shit about regular expressions and I don't even have wireless so I don't even know what kind of expression we're looking for, but the idea should be pretty solid.

After updating the lib you should have access to the IP variable, which you could use like it was already part of the lib. And if you do that you might want to commit your changes and submit a pull request to the person who made vicious. If you fail you might as well make an issue on github and they'll probably do it for you.

Last edited by naelstrof (2014-10-16 04:20:00)

Offline

#3 2014-10-16 05:22:51

n1x4
Member
From: Chernobyl
Registered: 2012-02-17
Posts: 149
Website

Re: [SOLVED]Awesomewm vicious wifi widget

Thank you for the help and  it gives me some thought. Also I must confess I feel the fool here. After installing vicious I didn't run updatedb therefore my locate results returned empty for the libs. Now i can see what I can call on in what lib so you in essence solved this for me. Long days, ugh. Again, vielen dank.


||github||

Offline

Board footer

Powered by FluxBB