The Original Prankster

Version: v0.1

Summary: A script a threw together to prank Mac users.

Code:

#!/bin/bash

#Customize what's in this area...

MinSleepTime=3
MaxSleepTime=10

WisperVol=13

Line[1]="Looking good today."
Line[2]="Hey Sexy!"
Line[3]="What are you doing?"
Line[4]="Are you ok?"
Line[5]="Help me!"
Line[6]="I can't get out!"
Line[7]="You look sad."
Line[8]="Do you ever get the feeling you are being watched?  You should."
Line[9]="I'm watching you."
Line[10]="Why are you not helping me?"
Line[11]="Would you like to play?"

Lines=11

#Don't customize anything below this area.
function setVolume() {
	TargetVol=${1}
	
	CurrentVol=`osascript -e "get output volume of (get Volume settings)"`
	
	if [ ${CurrentVol} -gt ${TargetVol} ]; then
		while [ ${CurrentVol} -gt ${TargetVol} ]; do
			NewVol=${CurrentVol}
			(( NewVol -= 2 ))
			echo "Turning volume down: ${NewVol}"
			osascript -e "set Volume output volume ${NewVol}"
			CurrentVol=`osascript -e "get output volume of (get Volume settings)"`
			echo "Volume is now: ${CurrentVol}"
			sleep .001
		done
	elif [ ${CurrentVol} -lt ${TargetVol} ]; then
		while [ ${CurrentVol} -lt ${TargetVol} ]; do
			NewVol=${CurrentVol}
			(( NewVol += 2 ))
			echo "Turning volume up: ${NewVol}"
			osascript -e "set Volume output volume ${NewVol}"
			CurrentVol=`osascript -e "get output volume of (get Volume settings)"`
			echo "Volume is now: ${CurrentVol}"
			sleep .001
		done
	fi	
}

function say() {
	Line=$1
	
	#Get Original Volume
	OriginalVol=`osascript -e "get output volume of (get Volume settings)"`
	
	#Adjust to target wisper volume.
	setVolume "${WisperVol}"
		
	#Speak
	echo "Speaking line: ${Line}"
	osascript -e "say "${Line}" using "Whisper""
	
	#Return to original volume
	setVolume "${OriginalVol}"
}

while [ true ]; do
	echo
	#Set sleep time.
	RandomSleepTime=`echo $((RANDOM%${MaxSleepTime}+${MinSleepTime}))`
	RandomSleepTime=$((RandomSleepTime*60))
	echo "Sleeping for ${RandomSleepTime} seconds."
	sleep ${RandomSleepTime}
	
	#Set Random Line Number
	RandomLine=`echo $((RANDOM%${Lines}+1))`
	say "${Line[${RandomLine}]}"
done

Directions:

  1. Give the script a “.command” extension.
  2. Drag into the users’ login items and check the “Hide” box.
  3. Sit back and enjoy yourself.

Changes:
v0.1: Initial Release

Leave a Reply

Your email address will not be published. Required fields are marked *