Skip to content

Instantly share code, notes, and snippets.

@youpy
Created January 6, 2011 09:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youpy/767717 to your computer and use it in GitHub Desktop.
Save youpy/767717 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'ubygems'
require 'osx/cocoa'
require 'osx/hotkey'
require 'rbosa'
require 'g'
def starrize(rating, max = 5)
'★' * rating + '☆' * (max - rating)
end
itunes = OSA.app('iTunes')
app = NSApplicationWithHotKey.sharedApplication
(0..5).to_a.each do |rating|
app.register_hotkey("Command+%i" % rating) do
track = itunes.current_track
track.rating = rating * 20
g '%s %s - %s' % [starrize(rating), track.artist, track.name]
end
end
app.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment