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

Weather widget breaks on multiple monitors. #424

Closed
yenson-lau opened this issue Apr 6, 2019 · 4 comments
Closed

Weather widget breaks on multiple monitors. #424

yenson-lau opened this issue Apr 6, 2019 · 4 comments
Labels

Comments

@yenson-lau
Copy link

Unfortunately I don't know my way around Awesome / Unix well enough to follow the steps outlined for awesome -v and lua -a whilst having Awesome broken, so I apologize in advance. But I'll do my best to outline the problem I ran into and how I got around it.

When I try to use the weather widget for my wibar on both my laptop and external display, this happens. Specifically I am told that when weather.show(t_out) tries to set

weather.notification = naughty.notify({
            text    = weather.notification_text,
            icon    = weather.icon_path,
            timeout = t_out,  -- bug seems to happen here
            preset  = notification_preset
        })

I am told by naughty/core.lua that there is an "attempt to compare number with table". This issue goes away if I simply comment out timeout = t_out.

The way I create my weather widget in my taskbar is to put the following in rc.lua:

local weather_font = beautiful.font
local markup = lain.util.markup
local weathericon = wibox.widget.imagebox(os.getenv("HOME") .. "/.config/awesome/themes/multicolor" .. "/icons/dish.png")
myweather = lain.widget.weather({
  city_id = 5128581, -- placeholder (London)
  notification_preset = { font = weather_font, fg = theme.fg_normal },
  weather_na_markup = markup.fontfg(weather_font, beautiful.fg_normal, "N/A "),
  settings = function()
    descr = weather_now["weather"][1]["description"]:lower()
    units = math.floor(weather_now["main"]["temp"])
    widget:set_markup(markup.fontfg(weather_font, beautiful.fg_normal, descr .. " " .. units .. '°C'))
  end})

-- some more code ...

awful.screen.connect_for_each_screen(function(s)
    -- Wallpaper
    set_wallpaper(s)

    -- Each screen has its own tag table.
    awful.tag({ "1", "2", "3", "4", "5" }, s, awful.layout.layouts[1])

    -- Create a promptbox for each screen
    s.mypromptbox = awful.widget.prompt()
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    s.mylayoutbox = awful.widget.layoutbox(s)
    s.mylayoutbox:buttons(gears.table.join(
                           awful.button({ }, 1, function () awful.layout.inc( 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(-1) end),
                           awful.button({ }, 4, function () awful.layout.inc( 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(-1) end)))
    -- Create a taglist widget
    s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)

    -- Create a tasklist widget
    s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)

    -- Create the wibox
    s.mywibox = awful.wibar({ position = "top", screen = s })

    -- Add widgets to the wibox
    s.mywibox:setup {
        layout = wibox.layout.align.horizontal,
        { -- Left widgets
            layout = wibox.layout.fixed.horizontal,
            mylauncher,
            s.mytaglist,
            s.mypromptbox,
            separator,
        },
        s.mytasklist, -- Middle widget
        { -- Right widgets
            layout = wibox.layout.fixed.horizontal,
            wibox.widget.systray(),
            mykeyboardlayout,
            separator,
            myweather,
            separator,
            mytextclock,
            s.mylayoutbox,
        },
    }
end)

I'm not sure if this is a real issue or if I'm just doing something incorrectly. Again, sorry if I'm not reporting this issue in the most efficient way possible due to lack of expertise...

@lcpz
Copy link
Owner

lcpz commented Apr 8, 2019

I do not know how that t_out becomes a table, so I added asserts.

Please git pull and check.

@yenson-lau
Copy link
Author

Unfortunately this doesn't seem to fix the issue. Perhaps naughty.notify with multiple monitors stores times separately? The documentation doesn't seem to say anything about that though.

@lcpz
Copy link
Owner

lcpz commented Apr 9, 2019

I didn't spot your errors: replace theme.fg_normal and myweather with beautiful.fg_normal and myweather.widget, respectively.

local myweather = lain.widget.weather {
    city_id = 5128581, -- placeholder (London)
    notification_preset = { font = beautiful.font, fg = beautiful.fg_normal },
    weather_na_markup = lain.util.markup.fontfg(beautiful.font, beautiful.fg_normal, "N/A "),
    settings = function()
        local descr = weather_now["weather"][1]["description"]:lower()
        local units = math.floor(weather_now["main"]["temp"])
        widget:set_markup(lain.util.markup.fontfg(beautiful.font, beautiful.fg_normal, descr .. " " .. units .. "°C"))
    end
}
awful.screen.connect_for_each_screen(function(s)
    -- Wallpaper
    set_wallpaper(s)

    -- Each screen has its own tag table.
    awful.tag({ "1", "2", "3", "4", "5" }, s, awful.layout.layouts[1])

    -- Create a promptbox for each screen
    s.mypromptbox = awful.widget.prompt()
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
    -- We need one layoutbox per screen.
    s.mylayoutbox = awful.widget.layoutbox(s)
    s.mylayoutbox:buttons(gears.table.join(
                           awful.button({ }, 1, function () awful.layout.inc( 1) end),
                           awful.button({ }, 3, function () awful.layout.inc(-1) end),
                           awful.button({ }, 4, function () awful.layout.inc( 1) end),
                           awful.button({ }, 5, function () awful.layout.inc(-1) end)))
    -- Create a taglist widget
    s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)

    -- Create a tasklist widget
    s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)

    -- Create the wibox
    s.mywibox = awful.wibar({ position = "top", screen = s })

    -- Add widgets to the wibox
    s.mywibox:setup {
        layout = wibox.layout.align.horizontal,
        { -- Left widgets
            layout = wibox.layout.fixed.horizontal,
            mylauncher,
            s.mytaglist,
            s.mypromptbox,
            separator,
        },
        s.mytasklist, -- Middle widget
        { -- Right widgets
            layout = wibox.layout.fixed.horizontal,
            wibox.widget.systray(),
            mykeyboardlayout,
            separator,
            myweather.widget,
            separator,
            mytextclock,
            s.mylayoutbox,
        },
    }
end)

@yenson-lau
Copy link
Author

Oh wow, this is embarassing. Thanks so much for catching these errors; sorry for the false alarm!

@lcpz lcpz added the invalid label Apr 9, 2019
bladecoates pushed a commit to bladecoates/lain that referenced this issue Jan 28, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants