Wireless status widget/watcher

Get wireless Quality link (converted to percentages) and wireless status.

Data is taken from /proc/net/wireless.

According to this website /proc/net/wireless has the following information:

This widget uses Quality - link and converts it to percentages (perc=Quality_link*10/7). The above equation is taken from this forum answer.

It also stores Status information (note that this is presumably device dependent).

Requirements

Usage

local widgets = {
    wirelessStatus = require("widgets/wirelessStatus"),
}
-- Wireless status widget (`status` is presumably device dependent)
theme.wirelessStatus = widgets.wirelessStatus({
    notification_preset = { font = "Mononoki Nerd Font 10", fg = theme.fg_normal },
    timeout = 10,
    settings = function(self)
        if self.status == "1" or self.status == "" then
            self.widget:set_image(theme.wifidisc)
        else
            if self.perc <= 5 then
                self.widget:set_image(theme.wifinone)
            elseif self.perc <= 25 then
                self.widget:set_image(theme.wifilow)
            elseif self.perc <= 50 then
                self.widget:set_image(theme.wifimed)
            elseif self.perc <= 75 then
                self.widget:set_image(theme.wifihigh)
            else
                self.widget:set_image(theme.wififull)
            end
        end
    end,
})
local widget_wirelessStatus = wibox.widget { nil, theme.wirelessStatus.widget, layout = wibox.layout.align.horizontal }
-- wirelessStatus widget pressed function - open terminal and start `nmtui`
beautiful.wirelessStatus.pressed = function(self, button)
    if button == 1 then  -- left mouse click
        awful.spawn(terminal.." -e nmtui")
    end
end