Skip to content

Instantly share code, notes, and snippets.

@grahams
Created February 22, 2012 15:35
Show Gist options
  • Save grahams/1885576 to your computer and use it in GitHub Desktop.
Save grahams/1885576 to your computer and use it in GitHub Desktop.
Jam this text into AppleScript Editor and save it into ~/Library/Scripts/iChat and use the Messages -> Preferences -> Alerts tab. Select "Run an AppleScript Script" and select this script. (Based on http://goo.gl/WUsrM.)
property growlAppName : "Growl iChat"
property notificationNames : {"Message Received", ¬
"Completed File Transfer"}
property defaultNotificationNames : {"Message Received", ¬
"Completed File Transfer"}
using terms from application "iChat"
on message received theText from theBuddy for theTextChat
my registerWithGrowl()
tell application "iChat"
set theIcon to image of theBuddy
set theTitle to full name of theBuddy
end tell
my notify(theTitle, theText, theIcon, "Message Received")
end message received
on completed file transfer theTransfer
my registerWithGrowl()
tell application "iChat"
tell theTransfer
if transfer status is finished then
if direction is incoming then
set theTitle to "Received File "
set theDesc to "from "
else
set theTitle to "Sent File "
set theDesc to "to "
end if
set theTitle to theTitle & (file as string)
set theDesc to theDesc & full name of buddy
end if
end tell
end tell
my notify(theTitle, theDesc, theIcon, "Message Received")
end completed file transfer
end using terms from
on registerWithGrowl()
tell application "Growl"
register as application growlAppName all notifications notificationNames default notifications notificationNames icon of application "iChat"
end tell
end registerWithGrowl
on notify(theTitle, desc, icondata, notificationName)
tell application "Growl"
if icondata is "" or icondata is missing value then
notify with name notificationName title theTitle description desc application name growlAppName icon of application "iChat"
else
notify with name notificationName title theTitle description desc application name growlAppName image icondata
end if
end tell
end notify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment