aboutsummaryrefslogtreecommitdiffstats
path: root/.config/luastatus-scripts-dwm/network.lua
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-25 19:14:21 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-25 19:14:21 +0530
commit8308de4e6cb44a84bd326cccd74a1017648aaabd (patch)
tree97068dee05327c442df99c40af2cc28cec212d15 /.config/luastatus-scripts-dwm/network.lua
parentc592fa0aca76ae2bd65a915d2df9152458ae8817 (diff)
modified dwm luastatus scripts
Diffstat (limited to '.config/luastatus-scripts-dwm/network.lua')
-rw-r--r--.config/luastatus-scripts-dwm/network.lua72
1 files changed, 72 insertions, 0 deletions
diff --git a/.config/luastatus-scripts-dwm/network.lua b/.config/luastatus-scripts-dwm/network.lua
new file mode 100644
index 0000000..4ec808a
--- /dev/null
+++ b/.config/luastatus-scripts-dwm/network.lua
@@ -0,0 +1,72 @@
+local MIN_DBM, MAX_DBM = -90, -20
+local NGAUGE = 5
+local COLOR_DIM = '#709080'
+
+local function round(x)
+ return math.floor(x + 0.5)
+end
+
+local function make_wifi_gauge(dbm)
+ if dbm < MIN_DBM then dbm = MIN_DBM end
+ if dbm > MAX_DBM then dbm = MAX_DBM end
+ local nbright = round(NGAUGE * (1 - 0.7 * (MAX_DBM - dbm) / (MAX_DBM - MIN_DBM)))
+
+ if nbright == 0 then
+ return "󰤭"
+ elseif nbright == 1 then
+ return "󰤯"
+ elseif nbright == 2 then
+ return "󰤟"
+ elseif nbright == 3 then
+ return "󰤢"
+ elseif nbright == 4 then
+ return "󰤥"
+ else
+ return "󰤨"
+ end
+end
+
+widget = {
+ plugin = 'network-linux',
+ opts = {
+ wireless = true,
+ timeout = 10,
+ },
+ cb = function(t)
+ if not t then
+ return nil
+ end
+
+ local x = ""
+ local sep = " "
+
+ if t.eno1 then
+ if t.eno1.ipv4 or t.eno1.ipv6 then
+ x = ""
+ end
+ end
+
+ if t.enp5s0f3u1 then
+ if x ~= "" then
+ x = x .. sep
+ end
+ if t.enp5s0f3u1.ipv4 or t.enp5s0f3u1.ipv6 then
+ x = x .. "󱎔"
+ end
+ end
+
+ if t.wlo1.wireless then
+ if x ~= "" then
+ x = x .. sep
+ end
+ if t.wlo1.wireless.signal_dbm then
+ x = x .. make_wifi_gauge(t.wlo1.wireless.signal_dbm)
+ else
+ x = x .. "󰤭"
+ end
+ end
+
+ x = " " .. x .. " "
+ return x
+ end,
+}