From a0f8b5fa6acdd1c2477fb1881dd9067956bf0ae6 Mon Sep 17 00:00:00 2001 From: delta Date: Sun, 29 Jan 2023 09:59:52 +0100 Subject: init dots --- .config/awesome/components/statusbar/wifi.lua | 60 +++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .config/awesome/components/statusbar/wifi.lua (limited to '.config/awesome/components/statusbar/wifi.lua') diff --git a/.config/awesome/components/statusbar/wifi.lua b/.config/awesome/components/statusbar/wifi.lua new file mode 100644 index 0000000..e6431ce --- /dev/null +++ b/.config/awesome/components/statusbar/wifi.lua @@ -0,0 +1,60 @@ +local awful = require "awful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" + +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("" .. icon .. "") + 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("" .. icon .. "") +end) + +local wifi = wibox.widget { + widget = wibox.container.place, + wifi_inner +} + +awful.tooltip { + objects = { wifi }, + timer_function = function() + return io.popen("iwgetid -r"):read("*a"):sub(0, -2) + end, + bg = vars.colors.bg, + fg = vars.colors.fg, + border_color = vars.colors.bright.black, + border_width = vars.border_width, + font = vars.font, + shape = vars.shape, + margin_leftright = dpi(6), + margin_topbottom = dpi(6) +} + +return wifi -- cgit v1.2.3