awesome: Show email counts in first wibox
This commit is contained in:
parent
582e822177
commit
44a9da16e7
1 changed files with 49 additions and 4 deletions
|
@ -8,10 +8,13 @@ local beautiful = require("beautiful")
|
|||
-- Notification library
|
||||
local naughty = require("naughty")
|
||||
local menubar = require("menubar")
|
||||
local lfs = require("lfs")
|
||||
|
||||
awful.rules = require("awful.rules")
|
||||
require("awful.autofocus")
|
||||
|
||||
local maildir_base = os.getenv("HOME") .. "/documents/mail/"
|
||||
|
||||
function ror(program, cls)
|
||||
local rorfunc = function ()
|
||||
local matcher = function (c)
|
||||
|
@ -31,6 +34,25 @@ function ror_combo(mod, key, program, class)
|
|||
function () awful.util.spawn(program) end))
|
||||
end
|
||||
|
||||
function new_mail(maildir)
|
||||
local count = 0
|
||||
|
||||
for file in lfs.dir(maildir_base .. maildir .. "/new") do
|
||||
if file ~= "." and file ~= ".." then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
for file in lfs.dir(maildir_base .. maildir .. "/cur") do
|
||||
if string.sub(file, -1) ~= "S" and file ~= "."
|
||||
and file ~= ".." then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
----- Error handling
|
||||
-- Check if awesome encountered an error during startup and fell back
|
||||
-- to another config (This code will only ever execute for the
|
||||
|
@ -135,12 +157,32 @@ mypromptbox = {}
|
|||
mylayoutbox = {}
|
||||
mytaglist = {}
|
||||
mytasklist = {}
|
||||
mymaillist = wibox.widget.textbox()
|
||||
mymaillist:set_text(
|
||||
string.format(" ryu: %d gmail: %d aethon: %d 9f: %d",
|
||||
new_mail('ryuslash.org/inbox'),
|
||||
new_mail('gmail/inbox'),
|
||||
new_mail('aethon/inbox'),
|
||||
new_mail('ninthfloor/inbox')))
|
||||
mymaillisttimer = timer({ timeout = 60 })
|
||||
mymaillisttimer:connect_signal(
|
||||
"timeout",
|
||||
function ()
|
||||
mymaillist:set_text(
|
||||
string.format(" ryu: %d gmail: %d aethon: %d 9f: %d",
|
||||
new_mail('ryuslash.org/inbox'),
|
||||
new_mail('gmail/inbox'),
|
||||
new_mail('aethon/inbox'),
|
||||
new_mail('ninthfloor/inbox')))
|
||||
end)
|
||||
mymaillisttimer:start()
|
||||
|
||||
for s = 1, screen.count() do
|
||||
-- Create a promptbox for each screen
|
||||
mypromptbox[s] = awful.widget.prompt()
|
||||
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
||||
-- We need one layoutbox per screen.
|
||||
-- Create an imagebox widget which will contains an icon
|
||||
-- indicating which layout we're using. We need one layoutbox per
|
||||
-- screen.
|
||||
mylayoutbox[s] = awful.widget.layoutbox(s)
|
||||
-- Create a taglist widget
|
||||
mytaglist[s] = awful.widget.taglist(
|
||||
|
@ -161,7 +203,10 @@ for s = 1, screen.count() do
|
|||
|
||||
-- Widgets that are aligned to the right
|
||||
local right_layout = wibox.layout.fixed.horizontal()
|
||||
if s == 1 then right_layout:add(wibox.widget.systray()) end
|
||||
if s == 1 then
|
||||
right_layout:add(mymaillist)
|
||||
right_layout:add(wibox.widget.systray())
|
||||
end
|
||||
right_layout:add(mytextclock)
|
||||
right_layout:add(mylayoutbox[s])
|
||||
|
||||
|
@ -251,7 +296,7 @@ globalkeys = awful.util.table.join(
|
|||
ror_combo({ modkey }, "c", 'urxvt', 'URxvt'),
|
||||
ror_combo({ modkey }, "w", 'conkeror', 'Conkeror'),
|
||||
awful.key({ "Control", "Mod1" }, "l",
|
||||
function () awful.util.spawn('i3lock -c 000000') end))
|
||||
function () awful.util.spawn('i3lock -c 000000') end))
|
||||
|
||||
clientkeys = awful.util.table.join(
|
||||
awful.key({ modkey, }, "f",
|
||||
|
|
Loading…
Reference in a new issue