Skip to content

Instantly share code, notes, and snippets.

@amir
Created July 14, 2009 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amir/147043 to your computer and use it in GitHub Desktop.
Save amir/147043 to your computer and use it in GitHub Desktop.
wirelessimagewidget = widget({ type = 'imagebox', align='right' })
wirelessimagewidget.image = image(beautiful.widget_wifi)
wirelesswidget = widget({ name = 'wireless', type = 'textbox', align = 'right' })
function wireless_status(format)
local sysfile = io.open("/sys/class/net/wlan0/operstate")
if sysfile == nil then
return { '' }
end
local operstate = sysfile:read()
sysfile:close()
if operstate == 'down' then
return { " <span color='red'>down</span>" }
end
local sysfile = io.open("/sys/class/net/wlan0/wireless/link")
local link = sysfile:read()
sysfile:close()
return { " " .. string.format("%.3d", link) .. "%% " }
end
wicked.register(wirelesswidget, wireless_status, "$1", 5, nul, nul)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment