aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar/widgets/wifi.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/awesome/ui/statusbar/widgets/wifi.lua')
-rw-r--r--.config/awesome/ui/statusbar/widgets/wifi.lua64
1 files changed, 26 insertions, 38 deletions
diff --git a/.config/awesome/ui/statusbar/widgets/wifi.lua b/.config/awesome/ui/statusbar/widgets/wifi.lua
index d0b7116..5f131b3 100644
--- a/.config/awesome/ui/statusbar/widgets/wifi.lua
+++ b/.config/awesome/ui/statusbar/widgets/wifi.lua
@@ -1,48 +1,36 @@
-local awful = require "awful"
-local vars = require "misc.vars"
+local qvars = require "quarrel.vars"
local wibox = require "wibox"
-local h = require "misc.helpers"
+local qmath = require "quarrel.math"
+local gcolor = require "gears.color"
+local phosphor = require "assets.phosphor"
-local wifi_inner = awful.widget.watch("awk 'NR==3 {printf(\"%.0f\", $3*10/7)}' /proc/net/wireless", 1, function(widget, stdout)
- widget.font = "DejaVu Sans Mono wifi ramp Normal 8"
- local icon = ""
- local color = vars.colors.red
+local wifi = wibox.widget {
+ widget = wibox.container.place,
+ valign = "center",
+ halign = "center",
+ {
+ widget = wibox.widget.imagebox,
+ image = gcolor.recolor_image(phosphor.wifi_x_fill, qvars.colors.red),
+ forced_width = qvars.icon_size,
+ forced_height = qvars.icon_size
+ }
+}
- if stdout == "" then
- widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>")
+awesome.connect_signal("services::wifi", function(strength, connected)
+ if not connected then
+ wifi.widget.image = gcolor.recolor_image(phosphor.wifi_x_fill, qvars.colors.red)
return
end
- local percent = tonumber(stdout)
-
- if percent <= 20 then
- icon = ""
- color = vars.colors.red
- elseif percent <= 40 then
- icon = ""
- color = vars.colors.yellow
- elseif percent <= 60 then
- icon = ""
- color = vars.colors.yellow
- elseif percent <= 80 then
- icon = ""
- color = vars.colors.green
- elseif percent <= 100 then
- icon = ""
- color = vars.colors.green
- end
-
-
- widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>")
-end)
-
-local wifi = wibox.widget {
- widget = wibox.container.place,
- wifi_inner
-}
+ local icon_data = qmath.step_value(strength, {
+ { 0, { "none", "red" } },
+ { 25, { "low", "yellow" } },
+ { 50, { "medium", "yellow" } },
+ { 75, { "high", "green" } },
+ { 100 }
+ })
-h.tooltip({ wifi }, function()
- return io.popen("iwgetid -r"):read("*a"):sub(0, -2)
+ wifi.widget.image = gcolor.recolor_image(phosphor["wifi_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]])
end)
return wifi