summaryrefslogtreecommitdiff
path: root/net-speed-widget
diff options
context:
space:
mode:
authorpolygon <polygon@wh2.tu-dresden.de>2021-05-22 11:59:51 +0200
committerpolygon <polygon@wh2.tu-dresden.de>2021-05-22 11:59:51 +0200
commit992916f0234fafc9c332ad91d20f11a901937d8a (patch)
tree06be975570a3702485cfa35656d524cbc7fd75a3 /net-speed-widget
parent11acce45064fc3917d65bc9ed0aedd1a6c1cda46 (diff)
Make net-speed width configurable with args
Diffstat (limited to 'net-speed-widget')
-rw-r--r--net-speed-widget/net-speed.lua61
1 files changed, 32 insertions, 29 deletions
diff --git a/net-speed-widget/net-speed.lua b/net-speed-widget/net-speed.lua
index 409e03d..3fc1090 100644
--- a/net-speed-widget/net-speed.lua
+++ b/net-speed-widget/net-speed.lua
@@ -15,35 +15,7 @@ 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 net_speed_widget = wibox.widget {
- {
- id = 'rx_speed',
- forced_width = 55,
- align = 'right',
- widget = wibox.widget.textbox
- },
- {
- image = ICONS_DIR .. 'down.svg',
- widget = wibox.widget.imagebox
- },
- {
- image = ICONS_DIR .. 'up.svg',
- widget = wibox.widget.imagebox
- },
- {
- id = 'tx_speed',
- forced_width = 55,
- align = 'left',
- widget = wibox.widget.textbox
- },
- layout = wibox.layout.fixed.horizontal,
- set_rx_text = function(self, new_rx_speed)
- self:get_children_by_id('rx_speed')[1]:set_text(tostring(new_rx_speed))
- end,
- set_tx_text = function(self, new_tx_speed)
- self:get_children_by_id('tx_speed')[1]:set_text(tostring(new_tx_speed))
- end
-}
+local net_speed_widget = {}
local prev_rx = 0
local prev_tx = 0
@@ -88,6 +60,37 @@ local function worker(user_args)
local interface = args.interface or '*'
local timeout = args.timeout or 1
+ local width = args.width or 55
+
+ local net_speed_widget = wibox.widget {
+ {
+ id = 'rx_speed',
+ forced_width = width,
+ align = 'right',
+ widget = wibox.widget.textbox
+ },
+ {
+ image = ICONS_DIR .. 'down.svg',
+ widget = wibox.widget.imagebox
+ },
+ {
+ image = ICONS_DIR .. 'up.svg',
+ widget = wibox.widget.imagebox
+ },
+ {
+ id = 'tx_speed',
+ forced_width = width,
+ align = 'left',
+ widget = wibox.widget.textbox
+ },
+ layout = wibox.layout.fixed.horizontal,
+ set_rx_text = function(self, new_rx_speed)
+ self:get_children_by_id('rx_speed')[1]:set_text(tostring(new_rx_speed))
+ end,
+ set_tx_text = function(self, new_tx_speed)
+ self:get_children_by_id('tx_speed')[1]:set_text(tostring(new_tx_speed))
+ end
+ }
local update_widget = function(widget, stdout)