user3261383
user3261383

Reputation: 303

Play a sound when AppleScript is done

I have no idea how to use AppleScript, how I got my little bash script working in the first place was beyond me. I'm currently using an AppleScript to run my bash script and it works fantastically. It is below.

do shell script "/Users/john/Scripts/screenshot -i --delete"

Now the bash script its referring to is that it will take a screenshot and upload it to my server, however;

I want it to play a sound when its done, how can I go about doing this? AppleScript is beyond my knowledge...

Upvotes: 20

Views: 20936

Answers (5)

AnonA
AnonA

Reputation: 1

Alfred 2 to assign global shortcut to do shell script "afplay /Users/john/Sounds/vengabus.aiff" + Spark for lion is good combo.

Upvotes: 0

Mr. Science
Mr. Science

Reputation: 39

You can play a random sound too!

do shell script "afplay /System/Library/Sounds/" & some item of paragraphs of ((do shell script "ls /System/Library/Sounds/")) ---random sound

Upvotes: 2

mklement0
mklement0

Reputation: 439287

Just to complement @adamh and @DigiMonk's excellent answers:

Good old beep can do the job if the default sound will do:

beep  # beep once

If once isn't enough, simply specify the desired number of beeps as an argument:

beep 2 # beep twice.

Incidentally, beep, say, and display notification are all defined in the User Interaction suite of dictionary StandardAdditions.sdef. To see these definitions, select File > Open Dictionary... in AppleScript Editor, and, in the list that pops up, select StandardAdditions.osax.

Upvotes: 13

user1804762
user1804762

Reputation:

The notification center (probably OS X 10.9.x only) can display messages with a sound.

set variableWithSoundName to "Glass"
display notification "Upload complete" with title "Screenshot" subtitle "Status" sound name variableWithSoundName

-- "sound name" is the name of a sound located in "~/Library/Sounds"
--  or "/System/Library/Sounds"

The display notification command is from the StandardAdditions.

(…and there is also the command beep which plays the default alert sound and takes the number of "beeps" as argument)

Upvotes: 13

adamh
adamh

Reputation: 3292

You can use afplay :

do shell script "afplay /Users/john/Sounds/vengabus.aiff"

or i like to use text to speech:

say "Finished!"

Upvotes: 29

Related Questions