diff options
author | streetturtle <streetturtle@users.noreply.github.com> | 2021-06-01 22:39:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 22:39:23 -0400 |
commit | 9628b67801f79d98b6a2c5a9b90e3b3e439b69f5 (patch) | |
tree | 05bf5106d7c5654fe3482af94af5412ca6f7443f | |
parent | da0786fd30862ebc3c4173a55f3cb0c85959116c (diff) | |
parent | 992916f0234fafc9c332ad91d20f11a901937d8a (diff) |
Merge pull request #265 from polygon/netspeed-width
Make net-speed width configurable with args
-rw-r--r-- | net-speed-widget/net-speed.lua | 61 |
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) |