Created
April 29, 2010 21:07
-
-
Save matchu/384244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Twitter Tracker for Ubuntu | |
# ========================== | |
# ruby twitter_tracker.rb user_to_track | |
# | |
# Will poll for updates from user_to_track every 30 seconds. Uses libnotify | |
# to let you know when we have something. Requires gems twitter, libnotify. | |
# | |
# Place image "twittericon.png" in this folder to get a nice icon on | |
# notifications. | |
require 'rubygems' | |
require 'libnotify' | |
require 'twitter' | |
Icon = File.join(File.dirname(File.expand_path(__FILE__)), 'twittericon.png') | |
Delay = 30 | |
username = ARGV[0] | |
old_message = nil | |
print "Tracking #{username}" | |
while true | |
user = Twitter.user(username) | |
new_message = user.status.text | |
if new_message == old_message | |
print "." | |
else | |
old_message = new_message | |
print "\n#{new_message}" | |
Libnotify.new do |n| | |
n.summary = "New tweet from #{username}" | |
n.body = new_message | |
n.icon_path = Icon | |
n.show! | |
end | |
end | |
sleep Delay | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment