Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I had a script under Snow Leopard that would upload a tiny file to my server when I launched iChat to reflect my status on my website. For some reason it doesn't work anymore in Lion.

Is there a way to trigger a shell script on online/offline status change in 10.7 without even launching iChat?

share|improve this question
    
Can you clarify what Lion's "on/offline status bubble" is? –  Daniel Lawson Nov 3 '11 at 0:08
    
Where did you get this script? Did you make it yourself? –  macaco Nov 3 '11 at 1:05
add comment

1 Answer 1

Option 1: run a script like this every minute or so with cron or launchd:

#!/bin/bash

cd=~/Library/Caches/me.lri.scripts
mkdir -p $cd
cf=$cd/ichatstatuscheck
status=$(osascript -e "tell app \"iChat\" to status")
[[ -f $cf && "$status" != $(cat $cf) ]] && say "$status"
echo "$status" > $cf

(The script activates iChat every time it's run.)


Option 2: save this as a stay open application in AppleScript Editor:

repeat
    tell application "iChat"
        set prev to status
        delay 5
        if status is not prev then do shell script "say " & quoted form of status
    end tell
end repeat

(Also activates iChat every time it gets the status.)


Option 3: use an iChat event handler (thanks Kopischke)

This worked for me on Lion, but only when iChat was active. (Not when it wasn't and I changed the status from iChat's status bar item — which I guess was the actual problem the OP had.)

share|improve this answer
    
All of these rely on actually launching iChat (via AppleScript, granted, but still) – which OP didn’t want to do. I think OP’s problem is that the status bar item for iChat (aka “iChat status bubble”) does not honor event handler settings – these seem to trigger only with iChat.app running. –  kopischke Nov 3 '11 at 13:16
    
Also, the second option doesn’t need to be run as a stay open application – you can bind a script to the login / logout events (which correspond to online / offline status) right inside iChat preferences (see previously linked post). –  kopischke Nov 3 '11 at 13:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.