lcpz / lain

Awesome WM complements
GNU General Public License v2.0
1.06k stars 210 forks source link

net widget units issue #514

Open t0m5k1 opened 3 years ago

t0m5k1 commented 3 years ago

Hi,

I've tried to read the wiki but I can't fathom why when U try to include a setting for units on the net widget it has no effect and doesn't produce an error.

❯ awesome -v
awesome v4.3 (Too long)
 • Compiled against Lua 5.3.5 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.6
 • LGI version: 0.9.2
❯ lua -v
Lua 5.4.3  Copyright (C) 1994-2021 Lua.org, PUC-Rio

My expected behaviour is that when I add units = 1024^2 the metrics displayed in the widget will change from a 4-5 digit number (8546.3) to a 1 or 2 digit number (5.6)

This is the widget I'm using:

-- Net
local neticon = wibox.widget.imagebox(theme.widget_net)
local net = lain.widget.net({

    settings = function()
    units = 1024^2
        widget:set_markup(markup.font(theme.font,
                markup("#7AC82E", " " .. net_now.received)
                    .. " " ..
                markup("#46A8C3", " " .. net_now.sent .. " ")))
    end
})

The units setting is being ignored as I still see a 4 digit number for received and sent, now considering my connection is 69 mb/ps I'd expect to see maybe 6.9 or lower if it was displaying megabytes.

I hope someone can help as I'm finding this quite confusing as I'm not a programmer and have no full grasp of lua.

Cheers

t0m5k1 commented 3 years ago

Resolved it by moving the units line:

-- Net
local neticon = wibox.widget.imagebox(theme.widget_net)
local net = lain.widget.net({
        units = 1024^2  --<<It needs to be placed here
    settings = function()
        widget:set_markup(markup.font(theme.font,
                markup("#7AC82E", " " .. net_now.received)
                    .. " " ..
                markup("#46A8C3", " " .. net_now.sent .. " ")))
    end
})

It really would be great if the wiki went into more detail about placement of these things. Cheers

lcpz commented 3 years ago

The wiki specifies that the input argument of the widget is a table, in which units and settings are two separate entities. Here, it also refers to awesome-copycats for examples. I thought these were enough details.

But I am obviously open to suggestions. Feel free to propose me modifications to the wiki.