You are not logged in.

#1 2012-03-19 21:00:14

shell
Member
Registered: 2012-03-19
Posts: 1

Awesome vicious wifi widget

Hi everyone,

i tried to build a wifiwidget and i looks like this:

-- Wifi

netwidget = widget({ type = "textbox" })
vicious.register(netwidget, vicious.widgets.wifi, '${ssid}' , 3, "wlan0")
neticon = widget({ type = "imagebox" })
vicious.register(neticon, vicious.widgets.wifi,
        function (widget, args)
                if "${link}" > 40 then
                        neticons.image=image(beautiful.widget_wifi_hi)
                elseif "${link}" > 20 and "${link}" <= 40 then
                        neticon.image=image(beautiful.widget_wifi_mid)
                elseif "${link}" > 0 and "${link}" <= 20 then
                        neticon.image=image(beautiful.widget_wifi_low)
                else
                        neticon.image=image(beautiful.widget_wifi_no)
                end
        end,
        3, "wlan0")

But now i get an error message:

attempt to compare number with string

I'm not a lua programmer so this might be look ... crazy ..

Any help would be great. Thanks!

Offline

#2 2012-03-23 20:56:07

PotatoesMaster
Member
From: France
Registered: 2010-08-26
Posts: 54

Re: Awesome vicious wifi widget

I don't know awesome.
But lua doesn't substitute variables in strings like shells do.
Try replacing all "${link}" with link.
And be sure that link is initialised.

vicious.register(neticon, vicious.widgets.wifi,
        function (widget, args)
                if link > 40 then
                        neticons.image=image(beautiful.widget_wifi_hi)
                elseif link > 20 then
                        -- link <= 40 is always true here because of the else keyword
                        neticon.image=image(beautiful.widget_wifi_mid)
                elseif link > 0 then
                        neticon.image=image(beautiful.widget_wifi_low)
                else
                        neticon.image=image(beautiful.widget_wifi_no)
                end
        end,
        3, "wlan0")

Offline

#3 2012-11-26 21:21:41

esa
Member
Registered: 2011-12-29
Posts: 143
Website

Re: Awesome vicious wifi widget

I have searched the net for wifi widgets, and this is the only one i could get working halfway.

I do get the ssid for the textwidget, however its missing the wifiicon, as i dont know lua i assume a coding error.
But my custom rc.lua is loaded successfully and is working, well all but the wifi icon.
I have added "wifiicon," to the widgets list for the systray.

	wifiwidget = widget({ type = "textbox" })
	vicious.register(wifiwidget, vicious.widgets.wifi, '${ssid}' , 11, wifi)
	
	wifiicon = widget({ type = "imagebox" })
	vicious.register(wifiicon, vicious.widgets.wifi,
		function (widget, args)
			link = args['{link}']
			-- wifiicon.visible = true	-- didnt help
			if link > 70 then
				wifiicon.image=image(beautiful.widget_wifi_hi)
			elseif link > 30 and link <= 70 then
				wifiicon.image=image(beautiful.widget_wifi_mid)
			elseif link > 0 and link <= 30 then
				wifiicon.image=image(beautiful.widget_wifi_low)
			else
				wifiicon.image=image(beautiful.widget_wifi_no)
			end
		end,
        	3, wifi)

Thank you for every input.
Regards
Simon


Author of: TUI (Text User Interface for scripts), VHS (Video Handler Script, using ffmpeg) and YASSI (Yet Another Simple Script Installer)

Offline

Board footer

Powered by FluxBB