Gigamo Wifi Widget

From awesome
Jump to: navigation, search

A simple wifi widget using "/sys/class/net".

Widget creation:

 wifiwidget = widget({type = "textbox", name = "wifiwidget", align = "right" })

The function:

 function wifiInfo(adapter)
     spacer = " "
     local f = io.open("/sys/class/net/"..adapter.."/wireless/link")
     local wifiStrength = f:read()
     if wifiStrength == "0" then
         wifiStrength = "Network Down"
     else
         wifiStrength = "Wifi:"..spacer..wifiStrength.."%"
     end
     wifiwidget.text = spacer..wifiStrength..spacer
     f:close()
 end

Then, call the function in a hook, like this:

 awful.hooks.timer.register(5, function()
     wifiInfo("wlan0")
 end)

Change the 5 to the time you want, or wlan0 to whichever adapter you use.

Personal tools