Skip to content

Instantly share code, notes, and snippets.

@mkb
Created September 15, 2011 02:31
Show Gist options
  • Save mkb/1218376 to your computer and use it in GitHub Desktop.
Save mkb/1218376 to your computer and use it in GitHub Desktop.
#!/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
@spacekat
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment