From 7b7ebbbc7c112961f08fb6d933aa01b6ad4769dc Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 7 Jan 2015 02:30:41 +0100 Subject: Use passive widgets This way awesome won't block when trying to get something and it takes a long time (like getting number of unread RSS articles without an internet connection). --- awesome/.config/awesome/rc.lua | 59 ++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 31 deletions(-) (limited to 'awesome') diff --git a/awesome/.config/awesome/rc.lua b/awesome/.config/awesome/rc.lua index 47a5223..71a2946 100644 --- a/awesome/.config/awesome/rc.lua +++ b/awesome/.config/awesome/rc.lua @@ -203,37 +203,30 @@ mytasklist.buttons = awful.util.table.join( if client.focus then client.focus:raise() end end)) -mymaillist = wibox.widget.textbox() -mymaillist:set_text( - string.format(" ryu: %d pfx: %d gmail: %d 9f: %d ", - new_mail('ryuslash.org/inbox'), - new_mail('picturefix/inbox'), - new_mail('gmail/inbox'), - new_mail('ninthfloor/inbox'))) -mymaillisttimer = timer({ timeout = 60 }) -mymaillisttimer:connect_signal( - "timeout", - function () - mymaillist:set_text( - string.format(" ryu: %d pfx: %d gmail: %d 9f: %d ", - new_mail('ryuslash.org/inbox'), - new_mail('picturefix/inbox'), - new_mail('gmail/inbox'), - new_mail('ninthfloor/inbox'))) - end) -mymaillisttimer:start() +function mailwidget(name, lighter) + widget = wibox.widget.textbox() + widget.set_mailcount = function (self) + self:set_text(string.format(" %s: %d", lighter, + new_mail(name .. '/inbox'))) + end + widget:set_mailcount() -if avandu then - myrsslist = wibox.widget.textbox() - myrsslist:set_markup(" " .. (avandu.unread() or '?') .. " ") - myrsslisttimer = timer({ timeout = 60 }) - myrsslisttimer:connect_signal( - "timeout", - function () - myrsslist:set_markup(" " .. (avandu.unread() or '?') .. " ") - end - ) - myrsslisttimer:start() + return widget +end + +mailwidgets = {ryuslash = mailwidget('ryuslash.org', 'ryu'), + picturefix = mailwidget('picturefix', 'pfx'), + gmail = mailwidget('gmail', 'gmail'), + ninthfloor = mailwidget('ninthfloor', '9f')} + +myrsslist = wibox.widget.textbox() +myrsslist.set_count = function (self, count) + if count then + self:set_markup(" " .. count + .. " ") + else + self:set_text("") + end end function unlocked() @@ -296,7 +289,11 @@ for s = 1, screen.count() do local right_layout = wibox.layout.fixed.horizontal() if s == 1 then if avandu then right_layout:add(myrsslist) end - right_layout:add(mymaillist) + + for k, w in pairs(mailwidgets) do + right_layout:add(w) + end + -- right_layout:add(mykeyringlist) right_layout:add(wibox.widget.systray()) end -- cgit v1.2.3-54-g00ecf