diff options
Diffstat (limited to 'net-speed-widget')
-rw-r--r-- | net-speed-widget/net-speed.lua | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/net-speed-widget/net-speed.lua b/net-speed-widget/net-speed.lua index 846898c..409e03d 100644 --- a/net-speed-widget/net-speed.lua +++ b/net-speed-widget/net-speed.lua @@ -8,7 +8,6 @@ -- @copyright 2020 Pavel Makhov ------------------------------------------------- -local naughty = require("naughty") local watch = require("awful.widget.watch") local wibox = require("wibox") @@ -16,14 +15,6 @@ local HOME_DIR = os.getenv("HOME") local WIDGET_DIR = HOME_DIR .. '/.config/awesome/awesome-wm-widgets/net-speed-widget/' local ICONS_DIR = WIDGET_DIR .. 'icons/' -local function show_warning(message) - naughty.notify { - preset = naughty.config.presets.critical, - title = 'Net Speed Widget', - text = message - } -end - local net_speed_widget = wibox.widget { { id = 'rx_speed', @@ -91,21 +82,21 @@ local function split(string_to_split, separator) return t end -local function worker(args) +local function worker(user_args) - local args = args or {} + local args = user_args or {} local interface = args.interface or '*' local timeout = args.timeout or 1 - local update_widget = function(widget, stdout, stderr) + local update_widget = function(widget, stdout) local cur_vals = split(stdout, '\r\n') local cur_rx = 0 local cur_tx = 0 - for i, v in ipairs(cur_vals) do + for i, _ in ipairs(cur_vals) do if i%2 == 1 then cur_rx = cur_rx + cur_vals[i] end if i%2 == 0 then cur_tx = cur_tx + cur_vals[i] end end @@ -120,7 +111,8 @@ local function worker(args) prev_tx = cur_tx end - watch(string.format([[bash -c "cat /sys/class/net/%s/statistics/*_bytes"]], interface), timeout, update_widget, net_speed_widget) + watch(string.format([[bash -c "cat /sys/class/net/%s/statistics/*_bytes"]], interface), + timeout, update_widget, net_speed_widget) return net_speed_widget |