aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/ui/statusbar/widgets/wifi.lua
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2023-03-04 22:04:55 +0100
committerdelta <darkussdelta@gmail.com>2023-03-04 22:18:21 +0100
commitf0b32f45746c026d402651013b7e98315d6956a1 (patch)
treef42609e98522da081cebdd21a674a702d1054bbc /.config/awesome/ui/statusbar/widgets/wifi.lua
parenta0f8b5fa6acdd1c2477fb1881dd9067956bf0ae6 (diff)
restructure awesome config, add fresnel
Diffstat (limited to '.config/awesome/ui/statusbar/widgets/wifi.lua')
-rw-r--r--.config/awesome/ui/statusbar/widgets/wifi.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/.config/awesome/ui/statusbar/widgets/wifi.lua b/.config/awesome/ui/statusbar/widgets/wifi.lua
new file mode 100644
index 0000000..d0b7116
--- /dev/null
+++ b/.config/awesome/ui/statusbar/widgets/wifi.lua
@@ -0,0 +1,48 @@
+local awful = require "awful"
+local vars = require "misc.vars"
+local wibox = require "wibox"
+local h = require "misc.helpers"
+
+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
+
+ if stdout == "" then
+ widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>")
+ 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
+}
+
+h.tooltip({ wifi }, function()
+ return io.popen("iwgetid -r"):read("*a"):sub(0, -2)
+end)
+
+return wifi