#!/usr/bin/ruby require 'rubygems' require 'httpclient' username = "username" password = "password" url = "https://mail.google.com/mail/feed/atom" client = HTTPClient.new client.set_auth(url, username, password) `touch .mail_count` # Oh, I know. file = File.open(".mail_count", "r+") oldcount = file.read.to_i while(1) resp = client.get(url) if (resp.content.to_s =~ /(\d+)<\/fullcount>/i) newcount = $~[1].to_i if newcount > oldcount `sudo eject` end oldcount = newcount file.pos = 0 file.write $~[1] end sleep(30) end