Skip to content

Instantly share code, notes, and snippets.

@frangio
Created May 24, 2011 00:17
Show Gist options
  • Save frangio/987921 to your computer and use it in GitHub Desktop.
Save frangio/987921 to your computer and use it in GitHub Desktop.
Checks Gmail and shows a Growl notification (using growlnotify) with unread count.
#! /usr/bin/env ruby
begin
response = %x{ curl -u username:password --silent "https://mail.google.com/mail/feed/atom" }
fullcount = response.match(/<fullcount>(\d+)<\/fullcount>/)[1].to_i
message = fullcount > 0 ? fullcount.to_s + " new message(s)." : "No new messages."
rescue
message = "There was an error."
ensure
%x{ growlnotify "#{message}" -m "" --image "icon.png" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment