Skip to content

Instantly share code, notes, and snippets.

@stepahn
Created July 22, 2011 11:27
Show Gist options
  • Save stepahn/1099278 to your computer and use it in GitHub Desktop.
Save stepahn/1099278 to your computer and use it in GitHub Desktop.
growl iChat
-- growl notifications for ichat, based on
-- http://scriptingosx.com/2010/11/ichat-notification-with-growl/
property growlAppName : "Growl iChat"
property notificationNames : {"Buddy Became Available", ¬
"Buddy Became Unavailable", ¬
"Message Received", ¬
"Completed File Transfer"}
property defaultNotificationNames : {"Buddy Became Available", ¬
"Buddy Became Unavailable", ¬
"Message Received", ¬
"Completed File Transfer"}
using terms from application "iChat"
on buddy became available theBuddy
tell application "iChat"
tell theBuddy
set theTitle to full name & " became available"
set theDesc to status message
set theIcon to image
end tell
end tell
my notify(theTitle, theDesc, theIcon, "Buddy Became Available")
end buddy became available
on buddy became unavailable theBuddy
tell application "iChat"
tell theBuddy
set theTitle to full name & " went away"
set theDesc to status message
set theIcon to image
end tell
end tell
my notify(theTitle, theDesc, theIcon, "Buddy Became Unavailable")
end buddy became unavailable
on message received theText from theBuddy for theTextChat
if my isBackground() then
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 if
end message received
on completed file transfer theTransfer
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 notify(theTitle, desc, icondata, notificationName)
try
if my isRunning() then
tell application id "com.Growl.GrowlHelperApp"
register as application growlAppName all notifications notificationNames default notifications notificationNames icon of application "iChat"
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 if
end try
end notify
on isRunning()
tell application "System Events" to ¬
(count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end isRunning
on isBackground()
tell application "System Events" to (name of first application process whose frontmost is true) is not "iChat"
end isBackground
@stepahn
Copy link
Author

stepahn commented Jul 22, 2011

this is the script from http://scriptingosx.com/2010/11/ichat-notification-with-growl.

I've adjusted it so it will not send growl notifications for received messages while iChat is in the foreground and updated it to work with the current AppStore version of Growl.

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