Created
October 16, 2011 04:18
-
-
Save nbqx/1290503 to your computer and use it in GitHub Desktop.
itunes.rb
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
| # -*- coding: utf-8 -*- | |
| require 'rbosa' ##gem install rubyosa or rubyosa19 | |
| def playing | |
| OSA.utf8_strings = true | |
| itunes = OSA.app('iTunes') | |
| if itunes.player_state == OSA::ITunes::EPLS::PLAYING | |
| track = itunes.current_track | |
| " ♪ "+track.artist.force_encoding("utf-8") + " - " + track.name.force_encoding("utf-8") | |
| else | |
| "" | |
| end | |
| end | |
| Earthquake.init do | |
| command %r|^:itunes\s+(.+)$|, :as => :itunes do |m| | |
| t = playing | |
| input(":update #{m[1]}#{t}") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment