summaryrefslogtreecommitdiff
path: root/network-widget
diff options
context:
space:
mode:
authorstreetturtle <streetturtle@gmail.com>2018-01-20 21:42:28 -0500
committerstreetturtle <streetturtle@gmail.com>2018-01-20 21:42:28 -0500
commit4239563581439be21de16642b12e92dbf7615310 (patch)
tree217c3c13f5b1834f88a003490d8913ee9aff5e43 /network-widget
parented3bbecb953c4b8166ca180b5fd5d49fa639114c (diff)
update README
Diffstat (limited to 'network-widget')
-rw-r--r--network-widget/network.lua27
-rwxr-xr-xnetwork-widget/networkio.sh7
2 files changed, 34 insertions, 0 deletions
diff --git a/network-widget/network.lua b/network-widget/network.lua
new file mode 100644
index 0000000..898be24
--- /dev/null
+++ b/network-widget/network.lua
@@ -0,0 +1,27 @@
+local awful = require("awful")
+local wibox = require("wibox")
+local watch = require("awful.widget.watch")
+
+local NETWORK_DEVICE = "/home/pmakhov/.config/awesome/awesome-wm-widgets/network-widget/networkio.sh"
+
+net_widget = wibox.widget {
+ font = "Play 9",
+ widget = wibox.widget.textbox
+}
+
+local rspeed_prev = 0;
+local tspeed_prev = 0;
+
+watch(NETWORK_DEVICE, 1,
+ function(widget, stdout, _, _, _)
+ local r, t = string.match(stdout, '(%d+);(%d+)')
+
+ local rspeed = r - rspeed_prev
+ local tspeed = t - tspeed_prev
+
+ rspeed_prev = r
+ tspeed_prev = t
+
+ widget:set_text(rspeed)
+ end,
+ net_widget)
diff --git a/network-widget/networkio.sh b/network-widget/networkio.sh
new file mode 100755
index 0000000..db3d774
--- /dev/null
+++ b/network-widget/networkio.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+ACTIVE_INTERFACE="$(ip -o link show | awk '$9~/UP/{sub(":","",$2);print $2}')"
+
+IO="$(cat /proc/net/dev | grep ${ACTIVE_INTERFACE} | sed "s/.*://" | awk '{printf $1";"$9}')"
+
+echo "${IO}"