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