Created
September 15, 2011 02:31
-
-
Save mkb/1218376 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby -wKU | |
LOG = 'eventcmd.log' | |
event = ARGV.first | |
@message = 'Gug.' | |
def ichat_message | |
%Q{set status message to "#{@message}"} | |
end | |
def adium_message | |
%Q{set status message of every account to "#{@message}"} | |
end | |
def applescript | |
%Q{ | |
tell application "System Events" | |
if exists process "iChat" then | |
tell application "iChat" | |
#{ichat_message} | |
end tell | |
end if | |
if exists process "Adium" then | |
tell application "Adium" | |
#{adium_message} | |
end tell | |
end if | |
end tell | |
} | |
end | |
def run_applescript | |
IO.popen("osascript", "w") { |f| f.puts(applescript) } | |
end | |
if event == 'songstart' | |
details = {} | |
$stdin.each_line do |l| | |
details.store(*l.chomp.split('=', 2)) | |
end | |
@message = %Q|now playing \\"#{details['title']}\\" by #{details['artist']}| | |
run_applescript | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup:
Open ~/.config/pianobar/config
Add "event_command" with the path to where you save this file.
(The same config where you can store your username and password for logging into pianobar)
Example:
event_command = /Users/username/hacks/adium_pianobar/my_coworkers_rock.rb