From 7913c08e261c09022bf20b03b0ac262edef5abec Mon Sep 17 00:00:00 2001 From: Dustin Swan Date: Tue, 29 Apr 2014 23:06:52 -0500 Subject: [PATCH] Adding ruby script to put notmuch inbox/unread count in os x menu bar. Tweaking afew filters --- afew/config | 11 +++++------ bin/notmuch_osx_menubar_count.rb | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100755 bin/notmuch_osx_menubar_count.rb diff --git a/afew/config b/afew/config index 6f3ba5d..47a0153 100644 --- a/afew/config +++ b/afew/config @@ -7,6 +7,8 @@ #[FolderNameFilter] #folder_blacklist = iocom/INBOX gmail/INBOX gmail/[Gmail].Important gmail/[Gmail].Starred #folder_transforms = Archive:archive Drafts:drafts Sent:sent Trash:trash Builder:builder Info:info Netmon:netmon Spam:spam "gmail/Kara Hetz":"Kara Hetz" "All Mail":archive "gmail/[Gmail].Drafts":drafts "gmail/[Gmail].Sent Mail":sent "Spam":spam "Important":important "gmail/[Gmail].Trash":trash +#folder_explicit_list = gmail/ +#folder_transforms = Archive:archive Drafts:drafts Sent:sent Trash:trash Builder:builder Info:info Netmon:netmon Spam:spam "gmail/Kara Hetz":"Kara Hetz" "All Mail":archive "gmail/[Gmail].Drafts":drafts "gmail/[Gmail].Sent Mail":sent "Spam":spam "Important":important "gmail/[Gmail].Trash":trash # This is getting nasty. Let's just use filters [Filter.1] @@ -73,15 +75,12 @@ tags = +bugzilla [InboxFilter] [MailMover] -folders = iocom/INBOX/ iocom/INBOX.Archive/ -#max_age = 15 +folders = iocom/INBOX/ iocom/INBOX.Archive/ gmail/INBOX/ +max_age = 15 iocom/INBOX/ = 'NOT tag:inbox':iocom/INBOX.Archive/ iocom/INBOX.Archive/ = 'tag:inbox':iocom/INBOX/ -gmail/INBOX = 'NOT tag:inbox':gmail/archive/ -#gmail/INBOX/ = 'NOT tag:inbox':"gmail/[Gmail].All Mail" -#gmail/[Gmail].Important/ = 'NOT tag:inbox':"gmail/[Gmail].All Mail" +gmail/INBOX/ = 'NOT tag:inbox':gmail/archive/ # TODO All folders <-> tags -# diff --git a/bin/notmuch_osx_menubar_count.rb b/bin/notmuch_osx_menubar_count.rb new file mode 100755 index 0000000..9df7b23 --- /dev/null +++ b/bin/notmuch_osx_menubar_count.rb @@ -0,0 +1,27 @@ +#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby + +require "osx/cocoa" +include OSX + +class Timer + def init + tick + end + def tick(a) + count = `notmuch count -- tag:inbox AND tag:unread` + foreground = count.to_i > 0 ? NSColor.whiteColor : NSColor.blackColor + background = count.to_i > 0 ? NSColor.colorWithSRGBRed_green_blue_alpha(0.8, 0.1, 0.1, 0.6) : NSColor.clearColor + dict = NSDictionary.dictionaryWithObjects_forKeys([background, foreground, NSFont.systemFontOfSize(16)], [NSBackgroundColorAttributeName, NSForegroundColorAttributeName, NSFontAttributeName]) + str = NSAttributedString.alloc().initWithString_attributes("\n ✉ " + count, dict) + $statusitem.setAttributedTitle(str) + end + def click(a) + NSLog("hiiii") + end +end + +app = NSApplication.sharedApplication +$statusitem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength) +NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(10.0, Timer.new, 'tick:', nil, true) + +app.run