Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net widget causes random crashes #464

Open
juacq97 opened this issue Oct 1, 2020 · 4 comments
Open

Net widget causes random crashes #464

juacq97 opened this issue Oct 1, 2020 · 4 comments

Comments

@juacq97
Copy link

juacq97 commented Oct 1, 2020

Hi! I want to use the net widget, here's my code:

 local mynet = lain.widget.net {
    iface = "wlp3s0",
    wifi_state = "on",
    settings = function()
       local wifi = net_now.devices.wlp3s0
       if wifi then
 	 net = "Connected"
       else
 	 net = "Disconnected"
       end
       widget:set_markup(net)
    end
 }

And I have my wibox setup:

    s.mywibox:setup {
       layout = wibox.layout.align.horizontal,
        { -- Left widgets
            layout = wibox.layout.fixed.horizontal,
            s.mylayoutbox,
            s.mytaglist,
        },
	mytextclock,
	expand = "none",
        { -- Right widgets
            layout = wibox.layout.fixed.horizontal,
	    myvol,
	    mysep,
	    mysep,
	    mybat,
	    mysep,
	    mysep,
	    mytemp,
	    mysep,
	    mysep,
	    mynet,
	    mysep,
        },

(Those mysep are just textboxes with spaces). When I restart awesome (including when I turn on the pc) sometimes I get an error. If I restart again the error is solved. After deactivating and activating all the widgets I conclude that is net the cause of the problem. There's some issue with my config file? Thanks!
awesome_error

@v6cc
Copy link
Contributor

v6cc commented Dec 2, 2020

same problem, Is there a way to solve this?

@imabuddha
Copy link

I was fighting this since yesterday when I started using this widget. The intermittent nature of the error really makes it difficult to debug. I tried many things to isolate it, but haven't found how to solve this in the lain code.

However, I did find a workaround:

  1. Don't put the lain.widget.net into your wibox!
  2. Create separate widgets to display the info from lain.widget.net and use those in your wibox.

Here's my use case which is adapted from copycats:

-- Net
local netdownicon = wibox.widget.imagebox(beautiful.widget_netdown)
local netdowninfo = wibox.widget.textbox()
local netupicon = wibox.widget.imagebox(beautiful.widget_netup)
local netupinfo = wibox.widget.textbox()

-- NOTE: actually using this widget in the wibar doesn't work reliably!
--      as shown on the lain wiki it will error on awesome reload intermittently!
--      this is caused by it trying to set 'devices' when the widget is "read only" ???
--      My solution is to use separate textbox widgets for display in wibar.
local netinfo = lain.widget.net({
    settings = function()
        netupinfo:set_markup(markup.fontfg(beautiful.font, "#e54c62", net_now.sent .. " "))
        netdowninfo:set_markup(markup.fontfg(beautiful.font, "#87af5f", net_now.received .. " "))
    end
})

--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- in the s.mywibox:setup right widgets block:
  
  netdownicon,
  netdowninfo,
  netupicon,
  netupinfo,

@RokasPuzonas
Copy link

I might have found the problem, and I believe the underlying reason is because the net widget is implemented by using a generic table.

-- ...
local function factory(args)
    args             = args or {}

    -- The line below is the line that causes all the problems
    local net        = { widget = args.widget or wibox.widget.textbox(), devices = {} }
    local timeout    = args.timeout or 2
    local units      = args.units or 1024 -- KB
    local notify     = args.notify or "on"
    local wifi_state = args.wifi_state or "off"
    local eth_state  = args.eth_state or "off"

   -- ...

   return net
end

From: https://github.com/lcpz/lain/blob/master/widget/net.lua#L20

The solution would be to actually use the wibox.widget.base.make_widget function that awesome provides.

The reason why I believe the generic table method breaks, because of how awesomewm parses widget layouts. After some digging in the awesomewm source code I couldn't really figure out exactly "why" it crashes. But I am really confident that after refactor the widget to use wibox.widget.base.make_widget would solve this problem.

@xfzv
Copy link

xfzv commented Apr 18, 2023

I was fighting this since yesterday when I started using this widget. The intermittent nature of the error really makes it difficult to debug. I tried many things to isolate it, but haven't found how to solve this in the lain code.

However, I did find a workaround:

1. Don't put the lain.widget.net into your wibox!

2. Create separate widgets to display the info from lain.widget.net and use _those_ in your wibox.

Here's my use case which is adapted from copycats:

-- Net
local netdownicon = wibox.widget.imagebox(beautiful.widget_netdown)
local netdowninfo = wibox.widget.textbox()
local netupicon = wibox.widget.imagebox(beautiful.widget_netup)
local netupinfo = wibox.widget.textbox()

-- NOTE: actually using this widget in the wibar doesn't work reliably!
--      as shown on the lain wiki it will error on awesome reload intermittently!
--      this is caused by it trying to set 'devices' when the widget is "read only" ???
--      My solution is to use separate textbox widgets for display in wibar.
local netinfo = lain.widget.net({
    settings = function()
        netupinfo:set_markup(markup.fontfg(beautiful.font, "#e54c62", net_now.sent .. " "))
        netdowninfo:set_markup(markup.fontfg(beautiful.font, "#87af5f", net_now.received .. " "))
    end
})

--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- in the s.mywibox:setup right widgets block:
  
  netdownicon,
  netdowninfo,
  netupicon,
  netupinfo,

Thank you, this method works just fine for me, the intermittent error is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants