Simple Maildir Biff Widget (Pure Lua)

by Fredrik Ax 

This widget uses a simple textbox widget to show the number of new and unread messages in a Maildir folder structure. It uses a timer hook to update the widget in intervals, but I might look into doing it with inotify in the next version. The update function uses find to recursively find new and "old" (lacking the Seen-flag) messages.

Everything is to be implemented in your awesome/lua.rc.

These globals are used for configuration: -- Root for Maildir tree to be checked mdbiffroot= "$HOME/Mail" -- Check interval (seconds) mdbiffint= 300

Creating the textbox, named mymdbiff: mymdbiff = widget({ type = "textbox", name = "mymdbiff", align = "right" }) Don't forget to add it to some statusbar for it to be useful ;-)

The function to be called by the timer hook: function hook_mdbiff local fh = io.popen("find "..mdbiffroot.." -type f -wholename '*/new/*' | wc -l") if fh == nil then mymdbiff.text = "&lt;b&gt;ERR&lt;/b&gt; ("    else          mymdbiff.text = "&lt;b&gt;"	         for l in fh:lines do             mymdbiff.text = mymdbiff.text .. l         end         io.close(fh)         mymdbiff.text = mymdbiff.text .. "&lt;/b&gt;"     end     fh = io.popen("find "..mdbiffroot.." -type f -regex '.*/cur/.*2,[^S]*$' | wc -l")     if fh == nil then         mymdbiff.text = mymdbiff.text .. " (ERR)"     else          mymdbiff.text = mymdbiff.text .. " (" for l in fh:lines do            mymdbiff.text = mymdbiff.text .. l        end io.close(fh) mymdbiff.text = mymdbiff.text .. ")"    end end Run the hook function from you rc.lua file once to initialize the widget. hook_mdbiff

Register the timer hook: awful.hooks.timer.register(mdbiffint, hook_mdbiff)

Add mouse click action: mymdbiff:mouse_add(mouse({ }, 1, function hook_mdbiff end))

Enjoy -- frax