aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar/panel/widgets/wifi.lua
blob: 8ccff959c9aa99c923c68648fe0e115ed04c3512 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local lgi = require "lgi"
local phosphor = require "assets.phosphor"
local qcolor = require "quarrel.color"
local qui = require "quarrel.ui"
local wibox = require "wibox"
local glib = lgi.GLib

local wifi_icon = qui.icon {
    icon = phosphor.wifi_x_fill,
    color = qcolor.palette.red(),
    widget = {
        id = "icon",
    },
}

local wifi = wibox.widget(qui.styled {
    widget = wibox.container.background,
    bg = qcolor.palette.bg.high,
    {
        widget = wibox.container.margin,
        margins = qui.BIG_PADDING,
        {
            {
                widget = wibox.container.place,
                valign = "center",
                halign = "center",
                wifi_icon,
            },
            {
                widget = wibox.widget.textbox,
                text = "Disconnected",
                id = "essid",
            },
            layout = wibox.layout.fixed.horizontal,
            spacing = qui.PADDING,
        },
    },
})

awesome.connect_signal("services::wifi", function(essid, _, connected)
    if connected then
        wifi:get_children_by_id("essid")[1].text = essid
    else
        wifi:get_children_by_id("essid")[1].text = "Disconnected"
    end
end)

awesome.connect_signal("services::wifi::icon", function(icon, color)
    wifi_icon.image = icon
    wifi_icon.stylesheet = qui.recolor(color)
end)

return wifi