Full path for curl

Full path for curl

Specified full path for curl

-- This is the master machq script to replace all others!
-- First find out the version of OS X

global osVersion
global externalIP
global SWUpdateServer
global store
global resources_directory

set osVersion to do shell script "/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'"

try
	set externalIP to do shell script "/usr/bin/curl http://icanhazip.com/"

	set test1 to do shell script "/usr/bin/dig +short 001.machq.com"
	set test2 to do shell script "/usr/bin/dig +short 002.machq.com"
	set test3 to do shell script "/usr/bin/dig +short 003.machq.com"

	if externalIP is test1 then
		set store to "001"
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if externalIP is test2 then
		set store to "002"
		set SWUpdateServer to "xserve.local:8088"
	else if externalIP is test3 then
		set store to "003"
		set SWUpdateServer to "servercdr.local:8088"
	end if

on error
	--can't determine which store automatically
	set theStoreList to {"St. Louis", "O'Fallon", "Cedar Rapids"}
	set theStore to choose from list theStoreList with title "Help!" with prompt "Where are we?"

	if theStore as string is "St. Louis" then
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if theStore as string is "O'Fallon" then
		set SWUpdateServer to "xserve.local:8088"
	else if theStore as string is "Cedar Rapids" then
		set SWUpdateServer to "servercdr.local:8088"
	end if

end try

--check for updates to the updater script
try
	tell application "Finder"
		set scripts_directory to (container of (path to me) as text)
		set resources_directory to (container of container of (path to me) as text)
	end tell

	set local_file to the POSIX path of (resources_directory & "updater.version")
	set local_version to do shell script "/bin/cat \"" & local_file & "\""

	set current_version to do shell script "/usr/bin/curl https://raw.githubusercontent.com/nilness/mhqtools/master/updater.version"
	--display dialog "Local version of updater is: " & local_version & ", current version is: " & current_version

	if current_version > local_version then

		--download the new version
		set local_file to the POSIX path of (scripts_directory & "updater.applescript")
		do shell script "/usr/bin/curl https://raw.githubusercontent.com/nilness/mhqtools/master/updater.applescript > \"" & local_file & "\""
		--update the local version string
		set local_file to the POSIX path of (resources_directory & "updater.version")
		do shell script "/usr/bin/curl https://raw.githubusercontent.com/nilness/mhqtools/master/updater.version > \"" & local_file & "\""

	end if
end try

tell application "Finder"
	set resources_directory to (container of container of (path to me) as text)
end tell

--display dialog osVersion buttons {"OK"}

--display dialog SWUpdateServer buttons {"OK"}

set theButtonNames to {"Set Used Prefs (all *'ed items)", "Set SWUpdateServer*", "List SWUpdateServer", "Remove SWUpdateServer", "Set MacHQ homepage*", "Disable Sleep*", "Rename HD by Size*", "Install MHQ Reset Script", "Remove Current User & Reset CPU", "Test for Flashback Trojan", "Test for ShellShock vulnerability", "Rebuild Launch Services DB", "Flush DNS Cache", "Reset Fake preferences", "Update Fake Workflows from Server", "Install SWUpdate StartupItem", "Save System Profiler Report to server"}

repeat
	set theChoice to choose from list theButtonNames
	if theChoice is false then
		exit repeat
	else if theChoice as string is "Set SWUpdateServer*" then
		setSWUpdateServer()
	else if theChoice as string is "List SWUpdateServer" then
		listSWUpdateServer()
	else if theChoice as string is "Remove SWUpdateServer" then
		resetSWUpdateServer()
	else if theChoice as string is "Set MacHQ homepage*" then
		setHomePage()
	else if theChoice as string is "Set Used Prefs (all *'ed items)" then
		setUsedPrefs()
	else if theChoice as string is "Disable Sleep*" then
		disableSleep()
	else if theChoice as string is "Rename HD by Size*" then
		renameHDbySize()
	else if theChoice as string is "Install MHQ Reset Script" then
		installResetScript()
	else if theChoice as string is "Remove MHQ User & Reset CPU" then
		if resetUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Remove Current User & Reset CPU" then
		if resetThisUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Test for Flashback Trojan" then
		testForFlashbackTrojan()
	else if theChoice as string is "Rebuild Launch Services DB" then
		rebuildLaunchServicesDB()
	else if theChoice as string is "Reset Fake preferences" then
		reinstallDefaultFakePreferences()
	else if theChoice as string is "Reinstall Fake Workflows" then
		reinstallFakeWorkflows()
	else if theChoice as string is "Install SWUpdate StartupItem" then
		InstallSWUpdatePlist()
	else if theChoice as string is "Flush DNS Cache" then
		FlushDNSCache()
	else if theChoice as string is "Save System Profiler Report to server" then
		SystemProfilerReport()
	else if theChoice as string is "Update Fake Workflows from Server" then
		UpdateWorkflowsFromServer()
	else if theChoice as string is "Test for ShellShock vulnerability" then
		testForShellShockVulnerability()
	else
		tell me to quit
	end if

end repeat

on setUsedPrefs()
	disableSleep()
	setSWUpdateServer()
	setHomePage()
	renameHDbySize()
end setUsedPrefs

on setHomePage()
	set fileTarget to (path to library folder from user domain as text) & "Preferences:com.apple.Safari.plist"

	try
		-- we don't really need the alias; we're just checking to see if it exists
		fileTarget as alias
	on error
		tell application "Safari"
			activate
		end tell
	end try
	if running of application "Safari" then
		tell application "Safari"
			quit
		end tell
		repeat while (running of application "Safari")
			delay 1
		end repeat
		delay 2
	end if
	do shell script "defaults write com.apple.Safari HomePage http://twitter.com/machq; defaults write com.apple.Safari NewWindowBehavior 0"
	delay 2
	tell application "Safari"
		activate
		delay 2
		close every window
		quit
	end tell
end setHomePage

on listSWUpdateServer()
	try
		set server_name to do shell script "defaults read /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		display dialog "SW update server is: " & server_name buttons {"OK"}
	on error
		display dialog "Using default Apple SW Update Server" buttons {"OK"}
	end try
end listSWUpdateServer

on resetSWUpdateServer()
	try
		--if running in 10.7 or later we need to supply password

		if (osVersion as number > 7) then
			do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL" with administrator privileges
		else
			do shell script "/usr/bin/defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		end if

		--do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
	end try
end resetSWUpdateServer

on disableSleep()
	try
		do shell script "pmset -c displaysleep 0 sleep 0 disksleep 0" with administrator privileges
	end try
end disableSleep

on renameHDbySize()
	set theSetScript to "

#!/bin/bash

boot_vol=`bless --getBoot`

boot_disk=`diskutil info ${boot_vol} |sed '/^ *Volume Name: */!d;s###'`

disk_size=`system_profiler SPSerialATADataType |sed '/^ *Capacity: */!d;s###' | awk '{print int($1+0.5)  $2\" HD\"}' | head -n 1 `

diskutil rename \"${boot_disk}\" \"${disk_size}\"

# Show icons for hard drives, servers, and removable media on the desktop
#defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
#defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
#defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true

killall Finder

"
	do shell script theSetScript

end renameHDbySize

on setSWUpdateServer()

	set theSetScript to "

#!/bin/bash

URL1='http://" & SWUpdateServer & "'
    case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
      4) URL=\"${URL1}/index.sucatalog\" ;;
      5) URL=\"${URL1}/index-leopard.merged-1.sucatalog\" ;;
      6) URL=\"${URL1}/index-leopard-snowleopard.merged-1.sucatalog\" ;;
	7) URL=\"${URL1}/index-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	8) URL=\"${URL1}/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	9) URL=\"${URL1}/index-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	10) URL=\"${URL1}/index-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
    esac

/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL \"${URL}\"

	"
	--if running in 10.7 or 10.8 we need to supply password
	try
		if (osVersion as number > 7) then
			do shell script theSetScript with administrator privileges
		else
			do shell script theSetScript
		end if
	end try
end setSWUpdateServer

on installResetScript()
	try
		tell application "Finder"
			set TheFile to (resources_directory & "mhqreset.sh") as alias
			duplicate TheFile to the startup disk with replacing
		end tell
	on error error_message
		display dialog error_message
	end try
end installResetScript

on resetUserCPU()
	try
		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()

		if osVersion is "10" then
			set target_file to ".bashrc"
		else
			set target_file to ".profile"
		end if

		do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/" & target_file with administrator privileges

		do shell script "nvram boot-args=\"-s\"" with administrator privileges

		tell application "Finder" to restart
		return -128
	end try
end resetUserCPU

on resetThisUserCPU()
	try
		tell application "System Events"
			set current_user to get the name of current user
		end tell

		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		display dialog "Are you absolutely certain?. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()

		if osVersion is "10" then
			set target_file to ".bashrc"
		else
			set target_file to ".profile"
		end if

		do shell script "echo \"sh /mhqreset.sh\" " & current_user & " >> /private/var/root/" & target_file with administrator privileges

		do shell script "nvram boot-args=\"-s\"" with administrator privileges

		tell application "Finder" to restart
		return -128
	end try
end resetThisUserCPU

on InstallSWUpdatePlist()

	set TheFile to (resources_directory & "Set SWUpdate Server") as alias

	if (osVersion as number > 7) then

		tell application "Finder"
			duplicate TheFile to (path to startup items from local domain as alias) with replacing
		end tell
	else

		set theScript to "

		#!/bin/bash

		if [ ! -e '/Library/StartupItems/Set SWUpdate Server' ]; then
		    mkdir '/Library/StartupItems/Set SWUpdate Server'
		fi
		cp -R '" & (the POSIX path of TheFile) & "' '/Library/StartupItems/Set SWUpdate Server/.'
		"
		do shell script theScript with administrator privileges

	end if

	do shell script "chmod -R 755 '/Library/StartupItems/Set SWUpdate Server'; sudo chown -R root:wheel '/Library/StartupItems/Set SWUpdate Server'" with administrator privileges

end InstallSWUpdatePlist

on testForFlashbackTrojan()
	display alert ("Beginning test") message "Testing for presence of Flashback trojan. Keep in mind this is NOT a definitive test!"

	try
		set check1 to do shell script "defaults read /Applications/Safari.app/Contents/Info LSEnvironment"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "First check appears okay"
		end if
	end try

	try
		set check2 to do shell script "defaults read ~/.MacOSX/environment DYLD_INSERT_LIBRARIES"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "Second check appears okay"
		end if
	end try
end testForFlashbackTrojan

on rebuildLaunchServicesDB()
	display alert ("Alert!") message "The Finder must be quit and will relaunch when complete."

	try
		tell application "Finder" to quit
		do shell script "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user"
		tell application "Finder" to activate

	end try
end rebuildLaunchServicesDB

on reinstallDefaultFakePreferences()

	--delete the current preference file

	tell application "Finder"
		set oldFile to (path to preferences folder as string) & "com.fakeapp.Fake.plist"
		delete file oldFile
	end tell

	-- create new preference file and set the properties we care about
	set theSetScript to "
#!/bin/bash

touch \"~/Preferences/com.fakeapp.Fake.plist\"
defaults write com.fakeapp.Fake \"FakeDelayBetweenRunningActions\" '0'
defaults write com.fakeapp.Fake \"FakePlaySuccessFailureSounds\" '0'
"
	do shell script theSetScript

end reinstallDefaultFakePreferences

on reinstallFakeWorkflows()
	set oldFolder to (path to application support from user domain as text) & "Fake:Workflows:"
	set fakeFolder to (path to application support from user domain as text) & "Fake:"
	set newFolder to (resources_directory & "Workflows") as alias
	--	display dialog oldFolder buttons {"OK"}
	tell application "Finder"
		try
			delete oldFolder
		end try
		duplicate newFolder to fakeFolder
	end tell
end reinstallFakeWorkflows

on FlushDNSCache()
	set theSetScript to "

#!/bin/bash

case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
    4) lookupd -flushcache ;;
   [56]) dscacheutil -flushcache ;;
    [78]) sudo killall -HUP mDNSResponder ;;
    9) dscacheutil -flushcache; sudo killall -HUP mDNSResponder ;;
  10) dscacheutil -flushcache; sudo discoveryutil mdnsflushcache ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
esac

	"
	--if running in 10.7 or 10.8 we need to supply password

	if (osVersion as number > 7) then
		do shell script theSetScript with administrator privileges
	else
		do shell script theSetScript
	end if
end FlushDNSCache

on SystemProfilerReport()

	if (store = "001") then
		set destination to "/Volumes/MHQ/Backed Up/System Profiler Reports/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://xserve.local/Service"
	else if (store = "003") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://servercdr.local/Service"
	end if

	--	display dialog oldFolder

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	--this shell script will generate a system profiler report and save it to the server
	do shell script "#!/bin/sh

# the location includes a folder based on the date in yyyy-mm-dd format
report_location=\"" & destination & "`date \"+%Y-%m-%d\"`/\"

if [ ! -d \"${report_location}\" ]; then
	mkdir \"${report_location}\"
fi

serial=`system_profiler SPHardwareDataType | grep \"Serial Number\" | awk  '{print $4}'`

SPDataTypes=\"SPHardwareDataType SPMemoryDataType SPPowerDataType SPSerialATADataType SPSoftwareDataType SPThunderboltDataType SPUSBDataType SPAirPortDataType SPFireWireDataType SPParallelATADataType SPAudioDataType SPBluetoothDataType SPNetworkDataType\"

system_profiler -xml $SPDataTypes > $report_location$serial\".spx\"
"

end SystemProfilerReport

on UpdateWorkflowsFromServer()

	set destination to POSIX path of ((path to application support from user domain as text) & "Fake:Workflows:")

	if (store = "001") then
		set source to "/Volumes/MHQ/Backed Up/Retail Stuff/Current Workflows/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://xserve.local/Retail"
	else if (store = "003") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://servercdr.local/Retail"
	end if

	--	display dialog oldFolder buttons {"OK"}

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	try
		set theScript to "
	#!/bin/bash

	/usr/bin/rsync -a '" & source & "' '" & destination & "'
	" --shell script

		do shell script theScript --with administrator privileges
	on error
		return "Error syncronizing folders."
	end try

end UpdateWorkflowsFromServer

on testForShellShockVulnerability()

	set test_1 to "
#!/bin/bash

EXPLOIT_1=`env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"`
if [ \"${EXPLOIT_1}\" = \"vulnerable\" ]; then
    echo \"Test 1 (CVE-2014-6271):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 1 (CVE-2014-6271):	Machine doesn't appear to be vulnerable\"
fi
"
	set test_2 to "
#!/bin/bash

EXPLOIT_2=`env X='() { (shellshocker.net)=>\\' bash -c \"echo date\"; cat echo; rm ./echo `
if [ \"${EXPLOIT_2}\" != \"date\" ]; then
    echo \"Test 2 (CVE-2014-7169):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 2 (CVE-2014-7169):	Machine doesn't appear to be vulnerable\"
fi
"
	set test_3 to "
#!/bin/bash

EXPLOIT_3=`env X=' () { }; echo hello' bash -c 'date'`
if [ \"${EXPLOIT_3}\" = \"hello\" ]; then
    echo \"Test 3 (CVE-??):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 3 (CVE-??):	Machine doesn't appear to be vulnerable\"
fi

"

	set test_4 to "
#!/bin/bash

EXPLOIT_4=`bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' || echo \"CVE-2014-7186 vulnerable, redir_stack\"`
if [ \"${EXPLOIT_4}\" = \"CVE-2014-7186 vulnerable, redir_stack\" ]; then
    echo \"Test 4 (CVE-2014-7186):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 4 (CVE-2014-7186):	Machine doesn't appear to be vulnerable\"
fi

"

	set test_5 to "
#!/bin/bash

EXPLOIT_5=`(for x in {1..200} ; do echo \"for x$x in ; do :\"; done; for x in {1..200} ; do echo done ; done) | bash || echo \"CVE-2014-7187 vulnerable, word_lineno\"`
if [ \"${EXPLOIT_5}\" = \"CVE-2014-7187 vulnerable, word_lineno\" ]; then
    echo \"Test 5 (CVE-2014-7187):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 5 (CVE-2014-7187):	Machine doesn't appear to be vulnerable\"
fi

"
	set test_6 to "
#!/bin/bash

EXPLOIT_6=`shellshocker='() { echo You are vulnerable; }' bash -c shellshocker`
if [ \"${EXPLOIT_6}\" = \"You are vulnerable\" ]; then
    echo \"Test 6 (CVE-2014-6278):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 6 (CVE-2014-6278):	Machine doesn't appear to be vulnerable\"
fi

"
	set test_7 to "
#!/bin/bash

EXPLOIT_7=`bash -c \"f() { x() { _;}; x() { _;} <<a; }\" 2>/dev/null || echo vulnerable`
if [ \"${EXPLOIT_7}\" = \"vulnerable\" ]; then
    echo \"Test 7 (CVE-2014-6277):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 7 (CVE-2014-6277):	Machine doesn't appear to be vulnerable\"
fi

"

	set result_1 to do shell script test_1
	set result_2 to do shell script test_2
	set result_3 to do shell script test_3
	set result_4 to do shell script test_4
	set result_5 to do shell script test_5
	set result_6 to do shell script test_6
	set result_7 to do shell script test_7

	try
		display dialog result_1 & return & result_2 & return & result_3 & return & result_4 & return & result_6 & return & result_6 & return & result_7 & return buttons {"OK"}
	end try
end testForShellShockVulnerability

-- This is the master machq script to replace all others!
-- First find out the version of OS X

global osVersion
global externalIP
global SWUpdateServer
global store
global resources_directory

set osVersion to do shell script "/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'"

try
	set externalIP to do shell script "/usr/bin/curl http://icanhazip.com/"

	set test1 to do shell script "/usr/bin/dig +short 001.machq.com"
	set test2 to do shell script "/usr/bin/dig +short 002.machq.com"
	set test3 to do shell script "/usr/bin/dig +short 003.machq.com"

	if externalIP is test1 then
		set store to "001"
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if externalIP is test2 then
		set store to "002"
		set SWUpdateServer to "xserve.local:8088"
	else if externalIP is test3 then
		set store to "003"
		set SWUpdateServer to "servercdr.local:8088"
	end if

on error
	--can't determine which store automatically
	set theStoreList to {"St. Louis", "O'Fallon", "Cedar Rapids"}
	set theStore to choose from list theStoreList with title "Help!" with prompt "Where are we?"

	if theStore as string is "St. Louis" then
		set SWUpdateServer to "mhq-swupdate.local:8088"
	else if theStore as string is "O'Fallon" then
		set SWUpdateServer to "xserve.local:8088"
	else if theStore as string is "Cedar Rapids" then
		set SWUpdateServer to "servercdr.local:8088"
	end if

end try

--check for updates to the updater script
try
	tell application "Finder"
		set scripts_directory to (container of (path to me) as text)
		set resources_directory to (container of container of (path to me) as text)
	end tell

	set local_file to the POSIX path of (resources_directory & "updater.version")
	set local_version to do shell script "/bin/cat \"" & local_file & "\""

	set current_version to do shell script "/usr/bin/curl https://raw.githubusercontent.com/nilness/mhqtools/master/updater.version"
	--display dialog "Local version of updater is: " & local_version & ", current version is: " & current_version

	if current_version > local_version then

		--download the new version
		set local_file to the POSIX path of (scripts_directory & "updater.applescript")
		do shell script "curl https://raw.githubusercontent.com/nilness/mhqtools/master/updater.applescript > \"" & local_file & "\""
		--update the local version string
		set local_file to the POSIX path of (resources_directory & "updater.version")
		do shell script "curl https://raw.githubusercontent.com/nilness/mhqtools/master/updater.version > \"" & local_file & "\""

	end if
end try

tell application "Finder"
	set resources_directory to (container of container of (path to me) as text)
end tell

--display dialog osVersion buttons {"OK"}

--display dialog SWUpdateServer buttons {"OK"}

set theButtonNames to {"Set Used Prefs (all *'ed items)", "Set SWUpdateServer*", "List SWUpdateServer", "Remove SWUpdateServer", "Set MacHQ homepage*", "Disable Sleep*", "Rename HD by Size*", "Install MHQ Reset Script", "Remove Current User & Reset CPU", "Test for Flashback Trojan", "Test for ShellShock vulnerability", "Rebuild Launch Services DB", "Flush DNS Cache", "Reset Fake preferences", "Update Fake Workflows from Server", "Install SWUpdate StartupItem", "Save System Profiler Report to server"}

repeat
	set theChoice to choose from list theButtonNames
	if theChoice is false then
		exit repeat
	else if theChoice as string is "Set SWUpdateServer*" then
		setSWUpdateServer()
	else if theChoice as string is "List SWUpdateServer" then
		listSWUpdateServer()
	else if theChoice as string is "Remove SWUpdateServer" then
		resetSWUpdateServer()
	else if theChoice as string is "Set MacHQ homepage*" then
		setHomePage()
	else if theChoice as string is "Set Used Prefs (all *'ed items)" then
		setUsedPrefs()
	else if theChoice as string is "Disable Sleep*" then
		disableSleep()
	else if theChoice as string is "Rename HD by Size*" then
		renameHDbySize()
	else if theChoice as string is "Install MHQ Reset Script" then
		installResetScript()
	else if theChoice as string is "Remove MHQ User & Reset CPU" then
		if resetUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Remove Current User & Reset CPU" then
		if resetThisUserCPU() = -128 then
			return
		end if
	else if theChoice as string is "Test for Flashback Trojan" then
		testForFlashbackTrojan()
	else if theChoice as string is "Rebuild Launch Services DB" then
		rebuildLaunchServicesDB()
	else if theChoice as string is "Reset Fake preferences" then
		reinstallDefaultFakePreferences()
	else if theChoice as string is "Reinstall Fake Workflows" then
		reinstallFakeWorkflows()
	else if theChoice as string is "Install SWUpdate StartupItem" then
		InstallSWUpdatePlist()
	else if theChoice as string is "Flush DNS Cache" then
		FlushDNSCache()
	else if theChoice as string is "Save System Profiler Report to server" then
		SystemProfilerReport()
	else if theChoice as string is "Update Fake Workflows from Server" then
		UpdateWorkflowsFromServer()
	else if theChoice as string is "Test for ShellShock vulnerability" then
		testForShellShockVulnerability()
	else
		tell me to quit
	end if

end repeat

on setUsedPrefs()
	disableSleep()
	setSWUpdateServer()
	setHomePage()
	renameHDbySize()
end setUsedPrefs

on setHomePage()
	set fileTarget to (path to library folder from user domain as text) & "Preferences:com.apple.Safari.plist"

	try
		-- we don't really need the alias; we're just checking to see if it exists
		fileTarget as alias
	on error
		tell application "Safari"
			activate
		end tell
	end try
	if running of application "Safari" then
		tell application "Safari"
			quit
		end tell
		repeat while (running of application "Safari")
			delay 1
		end repeat
		delay 2
	end if
	do shell script "defaults write com.apple.Safari HomePage http://twitter.com/machq; defaults write com.apple.Safari NewWindowBehavior 0"
	delay 2
	tell application "Safari"
		activate
		delay 2
		close every window
		quit
	end tell
end setHomePage

on listSWUpdateServer()
	try
		set server_name to do shell script "defaults read /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		display dialog "SW update server is: " & server_name buttons {"OK"}
	on error
		display dialog "Using default Apple SW Update Server" buttons {"OK"}
	end try
end listSWUpdateServer

on resetSWUpdateServer()
	try
		--if running in 10.7 or later we need to supply password

		if (osVersion as number > 7) then
			do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL" with administrator privileges
		else
			do shell script "/usr/bin/defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
		end if

		--do shell script "defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL"
	end try
end resetSWUpdateServer

on disableSleep()
	try
		do shell script "pmset -c displaysleep 0 sleep 0 disksleep 0" with administrator privileges
	end try
end disableSleep

on renameHDbySize()
	set theSetScript to "

#!/bin/bash

boot_vol=`bless --getBoot`

boot_disk=`diskutil info ${boot_vol} |sed '/^ *Volume Name: */!d;s###'`

disk_size=`system_profiler SPSerialATADataType |sed '/^ *Capacity: */!d;s###' | awk '{print int($1+0.5)  $2\" HD\"}' | head -n 1 `

diskutil rename \"${boot_disk}\" \"${disk_size}\"

# Show icons for hard drives, servers, and removable media on the desktop
#defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
#defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
#defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true

killall Finder

"
	do shell script theSetScript

end renameHDbySize

on setSWUpdateServer()

	set theSetScript to "

#!/bin/bash

URL1='http://" & SWUpdateServer & "'
    case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
      4) URL=\"${URL1}/index.sucatalog\" ;;
      5) URL=\"${URL1}/index-leopard.merged-1.sucatalog\" ;;
      6) URL=\"${URL1}/index-leopard-snowleopard.merged-1.sucatalog\" ;;
	7) URL=\"${URL1}/index-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	8) URL=\"${URL1}/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	9) URL=\"${URL1}/index-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
	10) URL=\"${URL1}/index-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog\" ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
    esac

/usr/bin/defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL \"${URL}\"

	"
	--if running in 10.7 or 10.8 we need to supply password
	try
		if (osVersion as number > 7) then
			do shell script theSetScript with administrator privileges
		else
			do shell script theSetScript
		end if
	end try
end setSWUpdateServer

on installResetScript()
	try
		tell application "Finder"
			set TheFile to (resources_directory & "mhqreset.sh") as alias
			duplicate TheFile to the startup disk with replacing
		end tell
	on error error_message
		display dialog error_message
	end try
end installResetScript

on resetUserCPU()
	try
		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()

		if osVersion is "10" then
			set target_file to ".bashrc"
		else
			set target_file to ".profile"
		end if

		do shell script "echo \"sh /mhqreset.sh\" >> /private/var/root/" & target_file with administrator privileges

		do shell script "nvram boot-args=\"-s\"" with administrator privileges

		tell application "Finder" to restart
		return -128
	end try
end resetUserCPU

on resetThisUserCPU()
	try
		tell application "System Events"
			set current_user to get the name of current user
		end tell

		display dialog "This will install the MHQ reset script and restart the computer into single user mode, then run the reset script automatically. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		display dialog "Are you absolutely certain?. The user \"" & current_user & "\" will be deleted with all it's files. Do you wish to continue?" buttons {"Quit", "Continue"} default button "Continue" cancel button "Quit"
		installResetScript()

		if osVersion is "10" then
			set target_file to ".bashrc"
		else
			set target_file to ".profile"
		end if

		do shell script "echo \"sh /mhqreset.sh\" " & current_user & " >> /private/var/root/" & target_file with administrator privileges

		do shell script "nvram boot-args=\"-s\"" with administrator privileges

		tell application "Finder" to restart
		return -128
	end try
end resetThisUserCPU

on InstallSWUpdatePlist()

	set TheFile to (resources_directory & "Set SWUpdate Server") as alias

	if (osVersion as number > 7) then

		tell application "Finder"
			duplicate TheFile to (path to startup items from local domain as alias) with replacing
		end tell
	else

		set theScript to "

		#!/bin/bash

		if [ ! -e '/Library/StartupItems/Set SWUpdate Server' ]; then
		    mkdir '/Library/StartupItems/Set SWUpdate Server'
		fi
		cp -R '" & (the POSIX path of TheFile) & "' '/Library/StartupItems/Set SWUpdate Server/.'
		"
		do shell script theScript with administrator privileges

	end if

	do shell script "chmod -R 755 '/Library/StartupItems/Set SWUpdate Server'; sudo chown -R root:wheel '/Library/StartupItems/Set SWUpdate Server'" with administrator privileges

end InstallSWUpdatePlist

on testForFlashbackTrojan()
	display alert ("Beginning test") message "Testing for presence of Flashback trojan. Keep in mind this is NOT a definitive test!"

	try
		set check1 to do shell script "defaults read /Applications/Safari.app/Contents/Info LSEnvironment"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "First check appears okay"
		end if
	end try

	try
		set check2 to do shell script "defaults read ~/.MacOSX/environment DYLD_INSERT_LIBRARIES"
		display alert ("Possible infection!") message "Recommend running full antivirus scan with up to date scanner. Please note this test is a first release and may produce false positives."

	on error error_message number error_number
		if error_number is equal to 1 then
			display alert ("Alert!") message "Second check appears okay"
		end if
	end try
end testForFlashbackTrojan

on rebuildLaunchServicesDB()
	display alert ("Alert!") message "The Finder must be quit and will relaunch when complete."

	try
		tell application "Finder" to quit
		do shell script "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user"
		tell application "Finder" to activate

	end try
end rebuildLaunchServicesDB

on reinstallDefaultFakePreferences()

	--delete the current preference file

	tell application "Finder"
		set oldFile to (path to preferences folder as string) & "com.fakeapp.Fake.plist"
		delete file oldFile
	end tell

	-- create new preference file and set the properties we care about
	set theSetScript to "
#!/bin/bash

touch \"~/Preferences/com.fakeapp.Fake.plist\"
defaults write com.fakeapp.Fake \"FakeDelayBetweenRunningActions\" '0'
defaults write com.fakeapp.Fake \"FakePlaySuccessFailureSounds\" '0'
"
	do shell script theSetScript

end reinstallDefaultFakePreferences

on reinstallFakeWorkflows()
	set oldFolder to (path to application support from user domain as text) & "Fake:Workflows:"
	set fakeFolder to (path to application support from user domain as text) & "Fake:"
	set newFolder to (resources_directory & "Workflows") as alias
	--	display dialog oldFolder buttons {"OK"}
	tell application "Finder"
		try
			delete oldFolder
		end try
		duplicate newFolder to fakeFolder
	end tell
end reinstallFakeWorkflows

on FlushDNSCache()
	set theSetScript to "

#!/bin/bash

case `/usr/bin/sw_vers -productVersion | /usr/bin/awk -F . '{print $2}'` in
    4) lookupd -flushcache ;;
   [56]) dscacheutil -flushcache ;;
    [78]) sudo killall -HUP mDNSResponder ;;
    9) dscacheutil -flushcache; sudo killall -HUP mDNSResponder ;;
  10) dscacheutil -flushcache; sudo discoveryutil mdnsflushcache ;;
      *) echo \"Unsupported client OS\"; exit 1 ;;
esac

	"
	--if running in 10.7 or 10.8 we need to supply password

	if (osVersion as number > 7) then
		do shell script theSetScript with administrator privileges
	else
		do shell script theSetScript
	end if
end FlushDNSCache

on SystemProfilerReport()

	if (store = "001") then
		set destination to "/Volumes/MHQ/Backed Up/System Profiler Reports/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://xserve.local/Service"
	else if (store = "003") then
		set destination to "/Volumes/Service/System Profiler Reports/"
		set dest_volume to "afp://servercdr.local/Service"
	end if

	--	display dialog oldFolder

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	--this shell script will generate a system profiler report and save it to the server
	do shell script "#!/bin/sh

# the location includes a folder based on the date in yyyy-mm-dd format
report_location=\"" & destination & "`date \"+%Y-%m-%d\"`/\"

if [ ! -d \"${report_location}\" ]; then
	mkdir \"${report_location}\"
fi

serial=`system_profiler SPHardwareDataType | grep \"Serial Number\" | awk  '{print $4}'`

SPDataTypes=\"SPHardwareDataType SPMemoryDataType SPPowerDataType SPSerialATADataType SPSoftwareDataType SPThunderboltDataType SPUSBDataType SPAirPortDataType SPFireWireDataType SPParallelATADataType SPAudioDataType SPBluetoothDataType SPNetworkDataType\"

system_profiler -xml $SPDataTypes > $report_location$serial\".spx\"
"

end SystemProfilerReport

on UpdateWorkflowsFromServer()

	set destination to POSIX path of ((path to application support from user domain as text) & "Fake:Workflows:")

	if (store = "001") then
		set source to "/Volumes/MHQ/Backed Up/Retail Stuff/Current Workflows/"
		set dest_volume to "afp://mhq-swupdate.local/MHQ"
	else if (store = "002") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://xserve.local/Retail"
	else if (store = "003") then
		set source to "/Volumes/Retail/Current Workflows/"
		set dest_volume to "afp://servercdr.local/Retail"
	end if

	--	display dialog oldFolder buttons {"OK"}

	tell application "Finder"
		try
			mount volume dest_volume
		on error
			return "Error mounting server volume \"" & dest_volume & "\". Please connect to server manually and try again."
			tell me to quit
		end try
	end tell

	try
		set theScript to "
	#!/bin/bash

	/usr/bin/rsync -a '" & source & "' '" & destination & "'
	" --shell script

		do shell script theScript --with administrator privileges
	on error
		return "Error syncronizing folders."
	end try

end UpdateWorkflowsFromServer

on testForShellShockVulnerability()

	set test_1 to "
#!/bin/bash

EXPLOIT_1=`env x='() { :;}; echo vulnerable' bash -c \"echo this is a test\"`
if [ \"${EXPLOIT_1}\" = \"vulnerable\" ]; then
    echo \"Test 1 (CVE-2014-6271):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 1 (CVE-2014-6271):	Machine doesn't appear to be vulnerable\"
fi
"
	set test_2 to "
#!/bin/bash

EXPLOIT_2=`env X='() { (shellshocker.net)=>\\' bash -c \"echo date\"; cat echo; rm ./echo `
if [ \"${EXPLOIT_2}\" != \"date\" ]; then
    echo \"Test 2 (CVE-2014-7169):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 2 (CVE-2014-7169):	Machine doesn't appear to be vulnerable\"
fi
"
	set test_3 to "
#!/bin/bash

EXPLOIT_3=`env X=' () { }; echo hello' bash -c 'date'`
if [ \"${EXPLOIT_3}\" = \"hello\" ]; then
    echo \"Test 3 (CVE-??):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 3 (CVE-??):	Machine doesn't appear to be vulnerable\"
fi

"

	set test_4 to "
#!/bin/bash

EXPLOIT_4=`bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' || echo \"CVE-2014-7186 vulnerable, redir_stack\"`
if [ \"${EXPLOIT_4}\" = \"CVE-2014-7186 vulnerable, redir_stack\" ]; then
    echo \"Test 4 (CVE-2014-7186):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 4 (CVE-2014-7186):	Machine doesn't appear to be vulnerable\"
fi

"

	set test_5 to "
#!/bin/bash

EXPLOIT_5=`(for x in {1..200} ; do echo \"for x$x in ; do :\"; done; for x in {1..200} ; do echo done ; done) | bash || echo \"CVE-2014-7187 vulnerable, word_lineno\"`
if [ \"${EXPLOIT_5}\" = \"CVE-2014-7187 vulnerable, word_lineno\" ]; then
    echo \"Test 5 (CVE-2014-7187):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 5 (CVE-2014-7187):	Machine doesn't appear to be vulnerable\"
fi

"
	set test_6 to "
#!/bin/bash

EXPLOIT_6=`shellshocker='() { echo You are vulnerable; }' bash -c shellshocker`
if [ \"${EXPLOIT_6}\" = \"You are vulnerable\" ]; then
    echo \"Test 6 (CVE-2014-6278):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 6 (CVE-2014-6278):	Machine doesn't appear to be vulnerable\"
fi

"
	set test_7 to "
#!/bin/bash

EXPLOIT_7=`bash -c \"f() { x() { _;}; x() { _;} <<a; }\" 2>/dev/null || echo vulnerable`
if [ \"${EXPLOIT_7}\" = \"vulnerable\" ]; then
    echo \"Test 7 (CVE-2014-6277):	**** Machine appears to be vulnerable ****\"
else
    echo \"Test 7 (CVE-2014-6277):	Machine doesn't appear to be vulnerable\"
fi

"

	set result_1 to do shell script test_1
	set result_2 to do shell script test_2
	set result_3 to do shell script test_3
	set result_4 to do shell script test_4
	set result_5 to do shell script test_5
	set result_6 to do shell script test_6
	set result_7 to do shell script test_7

	try
		display dialog result_1 & return & result_2 & return & result_3 & return & result_4 & return & result_6 & return & result_6 & return & result_7 & return buttons {"OK"}
	end try
end testForShellShockVulnerability


- from Br'fin, patch #642397: Applescript:Fix to handle spaces in path   This patch fixes bochs.applescript to handle a case where there are   spaces in the current path.

property bochs_path : "bochs.app/Contents/MacOS/bochs"

set script_name to name of (info for (path to me))
set script_path to POSIX path of (path to me)

-- replace target string using delimiters
set AppleScript's text item delimiters to the script_name
set the text_item_list to every text item of the script_path
set AppleScript's text item delimiters to ""
set the script_path to the text_item_list as string

tell application "Terminal"
	activate
	do script "cd \"" & script_path & "\";" & bochs_path
	-- Wait for Terminal to change the name first, then change it to ours
	delay 1
	set AppleScript's text item delimiters to "/"
	set the text_item_list to every text item of the script_path
	set AppleScript's text item delimiters to ""
	set next_to_last to ((count of text_item_list) - 1)
	set the folder_name to item next_to_last of text_item_list
	set name of front window to "Running bochs in ../" & folder_name & "/"
end tell

property bochs_path : "bochs.app/Contents/MacOS/bochs"

set script_name to name of (info for (path to me))
set script_path to POSIX path of (path to me)

-- replace target string using delimiters
set AppleScript's text item delimiters to the script_name
set the text_item_list to every text item of the script_path
set AppleScript's text item delimiters to ""
set the script_path to the text_item_list as string

tell application "Terminal"
	activate
	do script "cd " & script_path & ";" & bochs_path
	-- Wait for Terminal to change the name first, then change it to ours
	delay 1
	set AppleScript's text item delimiters to "/"
	set the text_item_list to every text item of the script_path
	set AppleScript's text item delimiters to ""
	set next_to_last to ((count of text_item_list) - 1)
	set the folder_name to item next_to_last of text_item_list
	set name of front window to "Running bochs in ../" & folder_name & "/"
end tell


Updated Snak AppleScript to behave properly for 0.6

FasdUAS 1.101.10
k
i
I0
registergrowl
registerGrowl
k

r

J
mPublic Message
mPrivate Message

o0allnotesallNotes
O
I
.registernullnull

appl
m

Snak

anot
o0allnotesallNotes

dnot
o0allnotesallNotes

iapp
m
Snak
m!!"nullaa;GrowlHelperApp.appL7P@)(K pGRRRalisWideBoy.1H+a3GrowlHelperApp.appa8v	 	Resources.1va3a2a1	TWideBoy:Library:PreferencePanes:Growl.prefPane:Contents:Resources:GrowlHelperApp.app&GrowlHelperApp.appWideBoyLLibrary/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app/"#
"l#$%
$l%&'
&i()
(I*
0pubmsg*+,
+o0con,-.
-o
0source./0
/o0
sourcehost012
1o
0target23
3o
0	thestring
)k4456
5l678
7l89:
9l;;VP################################################################################:<=
<l>>4.########	Edit these values to suit your wishes=?@
?lAAVP################################################################################@BC
BlCDE
DlFF:4 set ChannelsToMonitor to {"#example1", "#example2"}EGH
GlII/) set keywords to {"keyword1", "keyword2"}HJK
JrLM
LJ
Mo&0channelstomonitorChannelsToMonitorKNO
Nr	PQ
PJ
Qo0keywordsORS
Rl

STU
Tl

VVSM Set to false to popup notifications even when snak is the active applicationUWX
Wr

YZ
Ym

boovtrue
Zo00notifyinbackgroundonlyNotifyInBackgroundOnlyX[\
[l\]^
]l__VP################################################################################^`a
`lbb######### 	End Editable Regionacd
cleeWQ################################################################################	dfg
flghi
hlijk
jlklm
llnn)# Get the name of the topmost windowmop
oO$qr
qr#st
s6!uv
unwx
w1

pnam
x4y

prcs
ym
v= z{
z1

pisf
{m
boovtrue
to"0nameofactiveappNameOfActiveApp
rm||null

Finder.app΀0L7ΰp)(K MACSalisbWideBoy.1H+

Finder.app2	 CoreServices.1

.WideBoy:System:Library:CoreServices:Finder.app
Finder.appWideBoy&System/Library/CoreServices/Finder.app/p}~
}l%%~
l%%
l%%$ Get your current irc nickname
O%2
r)1
n)/
1-/

NICK
4)-

CONN
o+,0con
o
0mynick
m%&nullA߸`baSnakQP0L7ՀZ()(K ՠSNpaalisZWideBoy.1H+`baSnak`bۺtMt	 	Snak 4.13.1tM`ba|,WideBoy:Users:diggory:Desktop:Snak 4.13:Snak
SnakWideBoy$Users/diggory/Desktop/Snak 4.13/Snak/
l33
l33
l33NH First, make sure we are either focused on another app, or we want to be
l33'! notified even if Snak is on top
Z3
G3>
l36
>36
o34"0nameofactiveappNameOfActiveApp
m45
Snak
l9<
=9<
o9:00notifyinbackgroundonlyNotifyInBackgroundOnly
m:;
boovfals
kA
lAA
lAA
lAAa[ Make sure the message's target is in ChannelsToMonitor, or that ChannelsToMonitor is empty
ZA
lAN
GAN
EAD
oAB&0channelstomonitorChannelsToMonitor
oBC
0target
=GL
nGJ
1HJ

leng
oGH&0channelstomonitorChannelsToMonitor
mJK
kQ
lQQ
lQQHB if keywords is empty, we're successful and we display the message
lQQNH otherwise, only set success if the message contains one of our keywords
ZQ
lQV
=QV
nQT
1RT

leng
oQR0keywords
mTU
rY\
mYZ
boovtrue
o0keywordmatchkeywordMatch
k_
r_b
m_`
boovfals
o0keywordmatchkeywordMatch
Xc
Zs
lsv
Esv
ost
0	thestring
otu0thiskeywordthisKeyword
ry|
myz
boovtrue
o0keywordmatchkeywordMatch0thiskeywordthisKeyword
lfg
ofg0keywords
l
l;5 if the message contains our nick, we will display it
Z
l~
E
o}}
0	thestring
o||
0mynick~
r
m{
{boovtrue
ozz0keywordmatchkeywordMatchy
lxwxwy
lvuvu
lttmg If the message is coming from a valid channel, and we got success in matching either keywords or nick,
lss display an alert
Zrq
lp
=
ooo0keywordmatchkeywordMatch
mn
nboovtruep
k
n
Imlkm0
registergrowl
registerGrowllk
fj
O
Iih
i.notifygrnullnullhg
g
titl
l	f
	b

b

oee
0source

m:
odd
0targetfc
c
desc
lb
oaa
0	thestringb`
`
appl
m
Snak_^
_
name
mPublic Message^
m!jrq]
l\[\[]
lZYZYX
lWVWVX
lUTUTS
L
mR
RboovfalsS'
lQPQP !"
!lO#O#(" Log all private messages to growl"$%
$i&'
&IN(MN0privmsg()*
)oLL0con*+,
+oKK
0source,-.
-oJJ0
sourcehost./0
/oII
0target01H
1oGG
0	thestringHM
'kI2234
3lFEFE456
5lD7D7.( Get the name of the topmost application689
8O:;
:r<=
<6>?
>n
@A
@1
C
C
pnam
A4BB
B
prcs
BmAA
?=CD
C1@
@
pisf
Dm?
?boovtrue
=o>>"0nameofactiveappNameOfActiveApp
;m|9EF
El=<=<FGH
GZGIJ;:
IG"KL
KlM9
M>NO
No88"0nameofactiveappNameOfActiveApp
OmPP
Snak9
Ll Q7
Q= RS
Ro6600notifyinbackgroundonlyNotifyInBackgroundOnly
Sm5
5boovfals7
Jk%CTTUV
Un%*WX
WI&*43240
registergrowl
registerGrowl32
Xf%&VY1
YO+CZ[
ZI/B0/\
0.notifygrnullnull/\.]^
.
titl
]l16_-
_b16`a
`b14bc
bo12,,
0source
cm23dd:
ao45++
0target-^*ef
*
desc
el78g)
go78((
0	thestring)f'hi
'
appl
hm9:jj
Snaki&k%
&
name
km;<llPrivate Message%
[m+,!1;:Hm$
mlHH#"#"$%n!
nl  !opqro0
registergrowl
registerGrowl
0pubmsg0privmsgpst0
registergrowl
registerGrowls0allnotesallNotest!

appl

anot

dnot

iapp
.registernullnulllvEO*
Uq)
uv
0pubmsgww

0con
0source0
sourcehost
0target
0	thestring
u0con
0source0
sourcehost
0target
0	thestring&0channelstomonitorChannelsToMonitor0keywords00notifyinbackgroundonlyNotifyInBackgroundOnly"0nameofactiveappNameOfActiveApp
0mynick0keywordmatchkeywordMatch0thiskeywordthisKeywordv|x!

prcs

pnamx

pisf

CONN

NICK

bool

leng

kocl

cobj
.corecnte********0
registergrowl
registerGrowl

titl

desc

appl

name
.notifygrnullnulljvEOjvEOeEO*k/,[,\Ze81EUO
*/,EUO
f&
	,j&,jeEY8fEO![l
kheEYh[OYOeEYhOPOe1)j+O#*aa%%aaaaaaUYhOPYhOPYhOfr'yz0privmsg{{0con
0source0
sourcehost
0target
0	thestringy0con
0source0
sourcehost
0target
0	thestring"0nameofactiveappNameOfActiveApp00notifyinbackgroundonlyNotifyInBackgroundOnlyz|xP!djl

prcs

pnam

pisf

bool0
registergrowl
registerGrowl

titl

desc

appl

name
.notifygrnullnullJ*k/,[,\Ze81EUO
f&#)j+O*%%aUYhOPascrޭ

FasdUAS 1.101.10
k
i
I
0pubmsg

o0con

o
0source

o0
sourcehost
o
0target
o
0	thestring
k
l
l
lVP################################################################################
l4.########	Edit these values to suit your wishes
l  VP################################################################################!"
!l"#$
#l%%:4 set ChannelsToMonitor to {"#example1", "#example2"}$&'
&l((/) set keywords to {"keyword1", "keyword2"}')*
)r+,
+J
,o&0channelstomonitorChannelsToMonitor*-.
-r	/0
/J
0o0keywords.12
1l

234
3l

55SM Set to false to popup notifications even when snak is the active application467
6r

89
8m

boovtrue
9o00notifyinbackgroundonlyNotifyInBackgroundOnly7:;
:l;<=
<l>>VP################################################################################=?@
?lAA######### 	End Editable Region@BC
BlDDWQ################################################################################	CEF
ElFGH
GlHIJ
IlJKL
KlMM)# Get the name of the topmost windowLNO
NO$PQ
Pr#RS
R6!TU
TnVW
V1

pnam
W4X

prcs
Xm
U= YZ
Y1

pisf
Zm
boovtrue
So"0nameofactiveappNameOfActiveApp
Qm[[null%
Finder.appؠ07()( MACSalisbPanther4jH+%
Finder.app4$Je	 CoreServices4i%.Panther:System:Library:CoreServices:Finder.app
Finder.appPanther&System/Library/CoreServices/Finder.app/O\]
\l%%]^_
^l%%_`a
`l%%bb$ Get your current irc nicknameacd
cO%2ef
er)1gh
gn)/ij
i1-/

NICK
j4)-k

CONN
ko+,0con
ho
0mynick
fm%&llnullA߸&Snakp
ؠ07r,()( SNpaalis*Panther4jH+&SnaktM/
?	 Snak4itm&gPanther:Applications:Snak:Snak
SnakPantherApplications/Snak/Snak/dmn
ml33nop
ol33pqr
ql33ssNH First, make sure we are either focused on another app, or we want to bertu
tl33vv'! notified even if Snak is on top	uwx
wZ3yz
yG3>{|
{l36}
}>36~
~o34"0nameofactiveappNameOfActiveApp
m45
Snak
|l9<
=9<
o9:00notifyinbackgroundonlyNotifyInBackgroundOnly
m:;
boovfals
zkA
lAA
lAA
lAAa[ Make sure the message's target is in ChannelsToMonitor, or that ChannelsToMonitor is empty
ZA
lAN
GAN
EAD
oAB&0channelstomonitorChannelsToMonitor
oBC
0target
=GL
nGJ
1HJ

leng
oGH&0channelstomonitorChannelsToMonitor
mJK
kQ
lQQ
lQQHB if keywords is empty, we're successful and we display the message
lQQNH otherwise, only set success if the message contains one of our keywords
ZQ
lQV
=QV
nQT
1RT

leng
oQR0keywords
mTU
rY\
mYZ
boovtrue
o0keywordmatchkeywordMatch
k_
r_b
m_`
boovfals
o0keywordmatchkeywordMatch
Xc
Zs
lsv
Esv
ost
0	thestring
otu0thiskeywordthisKeyword
ry|
myz
boovtrue
o0keywordmatchkeywordMatch0thiskeywordthisKeyword
lfg
ofg0keywords
l
l;5 if the message contains our nick, we will display it
Z
l
E
o
0	thestring
o
0mynick
r
m
boovtrue
o0keywordmatchkeywordMatch
l
l
lmg If the message is coming from a valid channel, and we got success in matching either keywords or nick,
l display an alert
Z
l
=
o0keywordmatchkeywordMatch
m
boovtrue
O
I
.notifygrnullnull~
~
titl
b
b
o}}
0source
m:
o||
0target{
{
desc
ozz
0	thestringyx
y
iapp
m/Applications/Snak/Snakx
mLnullaGrowlHelperApp.app7@)( GRRRalisPanther4jH+BGrowlHelperApp.appDÚ	 	Resources4i4BA@9mQmP]bPanther:Users:justinb:Library:PreferencePanes:Growl.prefPane:Contents:Resources:GrowlHelperApp.app&GrowlHelperApp.appPantherZUsers/justinb/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app/w
lvuvuw
ltstsr
lqpqprx
lononm
L
ml
lboovfalsm
lkjkj
lii(" Log all private messages to growlh
i
Igfg0privmsg
oee0con
odd
0source
occ0
sourcehost
obb
0targeta
o``
0	thestringaf
k?
l_^_^

	l]].( Get the name of the topmost application

O
r
6
n

1
\
\
pnam
4[
[
prcs
mZZ
=
1Y
Y
pisf
mX
Xboovtrue
oWW"0nameofactiveappNameOfActiveApp
m[

lVUVU
Z=TS
G"
l!R
!>"#
"oQQ"0nameofactiveappNameOfActiveApp
#m$$
SnakR
 l %P
%= &'
&oOO00notifyinbackgroundonlyNotifyInBackgroundOnly
'mN
NboovfalsP
O%9()
(I)8ML*
M.notifygrnullnullL*K+,
K
titl
+b+0-.
-b+./0
/o+,JJ
0target
0m,-11:
.o./II
0source,H23
H
desc
2o12GG
0	thestring3F4E
F
iapp
4m3455Snak.appE
)m%&TS6D
6l>>CBCBDhA789A7@?@
0pubmsg?0privmsg8>=<:;;>
0pubmsg=:<:<9876590con8
0source70
sourcehost6
0target5
0	thestring<:43210/.-,+*)40con3
0source20
sourcehost1
0target0
0	thestring/&0channelstomonitorChannelsToMonitor.0keywords-00notifyinbackgroundonlyNotifyInBackgroundOnly,"0nameofactiveappNameOfActiveApp+
0mynick*0keywordmatchkeywordMatch)0thiskeywordthisKeyword;[('=&l%$#"!
(
prcs
'
pnam=
&
pisf
%
CONN
$
NICK
#
bool
"
leng
!
kocl

cobj
.corecnte********

titl

desc

iapp
.notifygrnullnull;jvEOjvEOeEO*k/,[,\Ze81EUO
*/,EUO
f&
	,j&t,jeEY8fEO![l
kheEYh[OYOeEYhOPOe#*a%%aaaaUYhOPYhOPYhOf9>?0privmsg@@0con
0source0
sourcehost
0target
0	thestring>

	0con
0source
0
sourcehost
0target
0	thestring
"0nameofactiveappNameOfActiveApp	00notifyinbackgroundonlyNotifyInBackgroundOnly?[=$15

prcs

pnam

pisf

bool

titl

desc

iapp
.notifygrnullnull@*k/,[,\Ze81EUO
f&*%%UYhOPascrޭ


Update wake-up script to switch to my remote speakers

-- Original script from Murphy Mac at http://murphymac.com/itunes-alarm-clock/
-- Start iTunes from cron and slowly bring volume up
tell application "System Events"
  tell process "iTunes"
     -- Switch to the speakers in my bedroom
     set frontmost to true
     click button 15 of window 1 -- Remote Speakers Menu
     key code 115                -- Home Key
     key code 125                -- Down Arrow
     key code 125                -- Down Arrow
     key code 36                 -- Return Key
  end tell
end tell

tell application "iTunes"
  set volume 1
  set sound volume to 1
  play playlist "Wake-Up"
  set x to 0

  repeat until x >= 100
    set x to x + 10
    if x <= 100 then set sound volume to x
    delay 30
  end repeat
end tell

-- Original script from Murphy Mac at http://murphymac.com/itunes-alarm-clock/
-- Start iTunes from cron and slowly bring volume up
tell application "iTunes"
     set volume 1
     set sound volume to 1
     play playlist "Wake-Up"
     set x to 0

     repeat until x >= 100
         set x to x + 10
         if x <= 100 then set sound volume to x
         delay 30
     end repeat
end tell


Obsidian

Obsidian

FasdUAS 1.101.10
k
i
I	0resize_app_window

o0app_name

o0win_position

o0win_size
Z=
=
n
1

prun
4

capp
o0app_name
m
boovtrue
O9
O8
k7
r&
J  !
 n"#
"4$

cobj
$m
#o0win_position!%
%n&'
&4(

cobj
(m
'o0win_position
n)*
)1#%

posn
*l #+
+2 #

cwin,
,r'7-.
-J'1//01
0n'+23
24(+4

cobj
4m)*
3o'(0win_size15
5n+/67
64,/8

cobj
8m-.
7o+,0win_size
.n9:
9146

ptsz
:l14;
;214

cwin
4<

prcs
<o0app_name
m==sevsalis\Macintosh HDBDSystem Events.app
 cuCoreServices0/:System:Library:CoreServices:System Events.app/$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/>?
>l?@A
@lB
BrCD
CJEEFG
FmGH
Hm$
Do0narrow_center_positionAIJ
Il
K
Kr
LM
LJNNOP
Om"PQ
Qm	m
Mo0narrow_center_sizeJRS
RlSTU
TlV
VrWX
WJYYZ[
Zm[\
\m$
Xo0wide_center_positionU]^
]l_
_r`a
`Jbbcd
cmde
emm
ao0wide_center_size^fg
flghi
hl$j
jI$k0resize_app_windowklm
lmnnoo1Password 7mpq
po0narrow_center_positionqr
ro 0narrow_center_sizeist
sl%-u
uI%-v0resize_app_windowvwx
wm&'yyzzApp Storex{|
{o'(0narrow_center_position|}
}o()0narrow_center_sizet~
~l.6
I.60resize_app_window
m/0Calendar
o010narrow_center_position
o120narrow_center_size
l7B
I7B0resize_app_window
m89CARROTweather
o9:0narrow_center_position
J:>
m:;"
m;<
lCM
ICM0resize_app_window
mDGFantastical
oGH0narrow_center_position
oHI0narrow_center_size
lNX
INX0resize_app_window
mORGoogle Chrome
oRS0narrow_center_position
oST0narrow_center_size
lYc
IYc0resize_app_window
mZ]Linear
o]^0narrow_center_position
o^_0narrow_center_size
ldn
Idn0resize_app_window
mehMail
ohi0narrow_center_position
oij0narrow_center_size
lo~}
Io|{|0resize_app_window
mpsMessages
Jsy
msvzzy
mvwxx$yw
Jy
my|vvu
m|}ttuw{~}
lsr
Iqpq0resize_app_window
mMicrosoft Teams
ooo0narrow_center_positionn
J
mmm"l
mkklnpsr
lji
Ihgh0resize_app_window
m
Music
off0narrow_center_positione
odd0narrow_center_sizeegji
lcb
Ia`a0resize_app_window
mNews
o__0narrow_center_position^
o]]0narrow_center_size^`cb
l\[
IZYZ0resize_app_window
m
Notes
oXX0narrow_center_positionW
oVV0narrow_center_sizeWY\[
l	UT
	IS
RS0resize_app_window

m

Notion
oQQ0narrow_center_positionP
oOO0narrow_center_sizePRUT
lNM
ILKL0resize_app_window
mObsidian
oJJ0narrow_center_positionI
oHH0narrow_center_sizeIKNM
lGF
IE DE0resize_app_window !"
!m##$$Photos"%&
%oCC0narrow_center_position&'B
'oAA0narrow_center_sizeBDGF()
(l*@?
*I>+=>0resize_app_window+,-
,m..//Pixelmator Pro-01
0o<<0narrow_center_position12;
2o::0narrow_center_size;=@?)34
3l598
5I76670resize_app_window678
7m99::Preview8;<
;o550narrow_center_position<=4
=o330narrow_center_size46984>?
>l@21
@I0A/00resize_app_windowABC
BmDDEERadarScopeCFG
Fo..0narrow_center_positionGH-
Ho,,0narrow_center_size-/21?IJ
IlK+*
KI)L()0resize_app_windowLMN
MmOOPPSafariNQR
Qo''0narrow_center_positionRS&
So%%0narrow_center_size&(+*JTU
Tl
V$#
VI
"W!"0resize_app_windowWXY
XmZZ[[SiftieY\]
\o  0narrow_center_position]^
^o0narrow_center_size!$#U_`
_la
aIb0resize_app_windowbcd
cmeeff
Slackdgh
go0narrow_center_positionhi
iJjjkl
km"lm
mm`no
nl#p
pI#q0resize_app_windowqrs
rmttuuSpotifysvw
vo0narrow_center_positionwx
xo0narrow_center_sizeoyz
yl$<{

{I$<|
0resize_app_window|}~
}m%(TextEdit~
J(0
m(+
m+.]
J08
m03R
m364

z
l=Q
I=Q0resize_app_window
m>ATweetbot
JAG
mAD
mDE$
JGM
mGJ
mJK
lR_
IR_0resize_app_window
mSVzoom.us
oVW0narrow_center_position
JW[
mWX"
mXY
0resize_app_window
.aevtoappnull****0narrow_center_position0narrow_center_size0wide_center_position0wide_center_size0resize_app_window0app_name0win_position0win_size0app_name0win_position0win_size=

capp

prun

prcs

cobj

cwin

posn

ptsz>*/,e3+*/#k/l/lv*-,FOk/l/lv*-,FUUYh
.aevtoappnull****
k_@IT]hs~(3>IT_ny+ny
#.9DOZet$0narrow_center_position"m0narrow_center_size0wide_center_position0wide_center_size0resize_app_window]R4`lvEOlvEOlvEOlvEO*m+O*m+O*m+O*lvm+O*am+O*am+O*am+O*am+O*aalvalvm+O*alvm+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*a m+O*a!m+O*a"m+O*a#lvm+O*a$m+O*a%aa&lva'a(lvm+O*a)alvalvm+O*a*lvm+$"m$mascr
ޭ

FasdUAS 1.101.10
k
i
I	0resize_app_window

o0app_name

o0win_position

o0win_size
Z=
=
n
1

prun
4

capp
o0app_name
m
boovtrue
O9
O8
k7
r&
J  !
 n"#
"4$

cobj
$m
#o0win_position!%
%n&'
&4(

cobj
(m
'o0win_position
n)*
)1#%

posn
*l #+
+2 #

cwin,
,r'7-.
-J'1//01
0n'+23
24(+4

cobj
4m)*
3o'(0win_size15
5n+/67
64,/8

cobj
8m-.
7o+,0win_size
.n9:
9146

ptsz
:l14;
;214

cwin
4<

prcs
<o0app_name
m==sevsalis\Macintosh HDBDSystem Events.app
 cuCoreServices0/:System:Library:CoreServices:System Events.app/$System Events.appMacintosh HD-System/Library/CoreServices/System Events.app/>?
>l?@A
@lB
BrCD
CJEEFG
FmGH
Hm$
Do0narrow_center_positionAIJ
Il
K
Kr
LM
LJNNOP
Om"PQ
Qm	m
Mo0narrow_center_sizeJRS
RlSTU
TlV
VrWX
WJYYZ[
Zm[\
\m$
Xo0wide_center_positionU]^
]l_
_r`a
`Jbbcd
cmde
emm
ao0wide_center_size^fg
flghi
hl$j
jI$k0resize_app_windowklm
lmnnoo1Password 7mpq
po0narrow_center_positionqr
ro 0narrow_center_sizeist
sl%-u
uI%-v0resize_app_windowvwx
wm&'yyzzApp Storex{|
{o'(0narrow_center_position|}
}o()0narrow_center_sizet~
~l.6
I.60resize_app_window
m/0Calendar
o010narrow_center_position
o120narrow_center_size
l7B
I7B0resize_app_window
m89CARROTweather
o9:0narrow_center_position
J:>
m:;"
m;<
lCM
ICM0resize_app_window
mDGFantastical
oGH0narrow_center_position
oHI0narrow_center_size
lNX
INX0resize_app_window
mORGoogle Chrome
oRS0narrow_center_position
oST0narrow_center_size
lYc
IYc0resize_app_window
mZ]Linear
o]^0narrow_center_position
o^_0narrow_center_size
ldn
Idn0resize_app_window
mehMail
ohi0narrow_center_position
oij0narrow_center_size
lo~}
Io|{|0resize_app_window
mpsMessages
Jsy
msvzzy
mvwxx$yw
Jy
my|vvu
m|}ttuw{~}
lsr
Iqpq0resize_app_window
mMicrosoft Teams
ooo0narrow_center_positionn
J
mmm"l
mkklnpsr
lji
Ihgh0resize_app_window
m
Music
off0narrow_center_positione
odd0narrow_center_sizeegji
lcb
Ia`a0resize_app_window
mNews
o__0narrow_center_position^
o]]0narrow_center_size^`cb
l\[
IZYZ0resize_app_window
m
Notes
oXX0narrow_center_positionW
oVV0narrow_center_sizeWY\[
l	UT
	IS
RS0resize_app_window

m

Notion
oQQ0narrow_center_positionP
oOO0narrow_center_sizePRUT
lNM
ILKL0resize_app_window
mPhotos
oJJ0narrow_center_positionI
oHH0narrow_center_sizeIKNM
lGF
IE DE0resize_app_window !"
!m##$$Pixelmator Pro"%&
%oCC0narrow_center_position&'B
'oAA0narrow_center_sizeBDGF()
(l*@?
*I>+=>0resize_app_window+,-
,m..//Preview-01
0o<<0narrow_center_position12;
2o::0narrow_center_size;=@?)34
3l598
5I76670resize_app_window678
7m99::RadarScope8;<
;o550narrow_center_position<=4
=o330narrow_center_size46984>?
>l@21
@I0A/00resize_app_windowABC
BmDDEESafariCFG
Fo..0narrow_center_positionGH-
Ho,,0narrow_center_size-/21?IJ
IlK+*
KI)L()0resize_app_windowLMN
MmOOPPSiftieNQR
Qo''0narrow_center_positionRS&
So%%0narrow_center_size&(+*JTU
Tl
V$#
VI
"W!"0resize_app_windowWXY
XmZZ[[
SlackY\]
\o  0narrow_center_position]^
^J	__`a
`m"ab
bm!$#Ucd
cle
eIf0resize_app_windowfgh
gmiijjSpotifyhkl
ko0narrow_center_positionlm
mo0narrow_center_sizedno
nl1p
pI1q0resize_app_windowqrs
rmttuuTextEditsvw
vJ%xxyz
ym z{
{m #]w|

|J%-}}~
~m%(R
m(+

4
o
l2F
I2F0resize_app_window
m36Tweetbot
J6<
m69
m9:$
J<B
m<?
m?@
lGT
IGT0resize_app_window
mHKzoom.us
oKL0narrow_center_position
JLP
mLM"
mMN0resize_app_window
.aevtoappnull****0resize_app_window0app_name0win_position0win_size0app_name0win_position0win_size=

capp

prun

prcs

cobj

cwin

posn

ptsz>*/,e3+*/#k/l/lv*-,FOk/l/lv*-,FUUYh
.aevtoappnull****
kT@IT]hs~(3>ITcn*ny
#.9DOZit$0narrow_center_position"m0narrow_center_size0wide_center_position0wide_center_size0resize_app_window]R4UlvEOlvEOlvEOlvEO*m+O*m+O*m+O*lvm+O*am+O*am+O*am+O*am+O*aalvalvm+O*alvm+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*am+O*a m+O*a!m+O*a"lvm+O*a#m+O*a$aa%lva&a'lvm+O*a(alvalvm+O*a)lvm+ascr
ޭ


Add support for cmd-c and cmd-l on results

-- core configuration --

-- configurable options --

-- limit number of songs to improve efficiency
property resultLimit : 15
-- whether or not to retrieve/display album artwork for each result
property albumArtEnabled : true

-- workflow parameters --

-- workflow folders
property libraryFolder : (path to library folder from user domain as text)
property cacheFolder : (libraryFolder & "Caches:")
property alfredWorkflowDataFolder : (cacheFolder & "com.runningwithcrayons.Alfred:Workflow Data:")
property bundleId : "com.calebevans.playsong"
property workflowCacheFolder : (alfredWorkflowDataFolder & bundleId & ":") as text

-- the default icon used for search results without album artwork
property defaultIconName : "resources/icon-noartwork.png"
-- the name of the playlist used by the workflow for playing songs
property workflowPlaylistName : "Alfred Play Song"
-- list of Alfred results
property resultList : {}

-- replaces substring in string with another substring
on replace(replaceThis, replaceWith, theString)

	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to replaceThis
	set strItems to text items of theString
	set AppleScript's text item delimiters to replaceWith
	set newString to strItems as text
	set AppleScript's text item delimiters to oldDelims
	return newString

end replace

-- retrieve the plural/singular form of a quantity based on the given number
on quantifyNumber(theNumber, quantityName, pluralQuantityName)

	if theNumber is 1 then

		set theString to (theNumber as text) & space & quantityName

	else

		set theString to (theNumber as text) & space & pluralQuantityName

	end if

	return theString

end quantifyNumber

-- encodes JSON reserved characters in the given string
on encodeFeedbackChars(theString)

	set theString to replace("\\", "\\\\", theString)
	set theString to replace("\"", "\\\"", theString)
	return theString

end encodeFeedbackChars

-- decodes JSON reserved characters in the given string
on decodeFeedbackChars(theString)

	set theString to replace("\\\\", "\\", theString)
	set theString to replace("\\\"", "\"", theString)
	return theString

end decodeFeedbackChars

-- adds Alfred result to result list
on addResult(theResult)

	copy theResult to the end of resultList

end addResult

-- adds item for "No Results" message
on addNoResultsItem(query, queryType)

	addResult({uid:"no-results", valid:"no", title:"No Results Found", subtitle:("No " & queryType & "s matching '" & query & "'"), icon:defaultIconName})

end addNoResultsItem

on resultListIsFull()

	return (length of resultList is resultLimit)

end resultListIsFull

on resultListIsEmpty()

	return (length of resultList is 0)

end resultListIsFull

-- builds Alfred result item as JSON
on getResultFeedback(theResult)

	-- encode reserved JSON characters
	set resultUid to encodeFeedbackChars(uid of theResult)
	set resultValid to (valid of theResult) as text
	set resultTitle to encodeFeedbackChars(title of theResult)
	set resultSubtitle to encodeFeedbackChars(subtitle of theResult)

	if (icon of theResult) contains ":" then

		set resultIcon to encodeFeedbackChars(POSIX path of icon of theResult)

	else

		set resultIcon to icon of theResult

	end if

	set json to "{"
	set json to json & "\"uid\":\"" & resultUid & "\","
	set json to json & "\"arg\":\"" & resultUid & "\","
	set json to json & "\"valid\":\"" & resultValid & "\","
	set json to json & "\"title\":\"" & resultTitle & "\","
	set json to json & "\"subtitle\":\"" & resultSubtitle & "\","
	set json to json & "\"text\":{"
	set json to json & "\"copy\":\"" & resultTitle & "\","
	set json to json & "\"largetype\":\"" & resultTitle & "\""
	set json to json & "},"
	set json to json & "\"icon\":{\"path\":\"" & resultIcon & "\"}"
	set json to json & "}"
	return json

end getResultFeedback

-- retrieves JSON document for Alfred results
on getResultListFeedback()

	set json to "{\"items\": ["

	repeat with theResult in resultList

		set json to json & getResultFeedback(theResult)
		set json to json & ","

	end repeat

	-- remove trailing comma after last item
	set json to text 1 thru (length of json - 1) of json
	set json to json & "]}"
	return json

end getResultListFeedback

-- query path to artwork image file cached natively by Music.app in Catalina
on getSongArtworkPath(theSong)

	try

		if albumArtEnabled is false then return defaultIconName

		tell application "Music"

			-- get persistent ID of song and use it to fetch album artwork
			set songId to persistent ID of theSong
			-- the base path to the artwork file (without extension)
			set artworkPath to (do shell script "./resources/get-song-artwork-path.sh" & space & songId & space & defaultIconName)

		end tell

		return artworkPath

	on error errorMessage

		log errorMessage

	end try

end getSongArtworkPath

-- creates album artwork cache
on createWorkflowPlaylist()

	tell application "Music"

		if not (user playlist workflowPlaylistName exists) then

			make new user playlist with properties {name:workflowPlaylistName, shuffle:false}

		end if

	end tell

end createWorkflowPlaylist

on clearQueue()

	tell application "Music"

		if user playlist workflowPlaylistName exists then

			delete tracks of user playlist workflowPlaylistName

		end if

	end tell

end clearQueue

on queueSongs(theSongs)

	tell application "Music"

		repeat with theSong in theSongs

			duplicate theSong to user playlist workflowPlaylistName

		end repeat

	end tell

end queueSongs

on playQueue()

	tell application "Music"

		if number of tracks in user playlist workflowPlaylistName is not 0 then

			play user playlist workflowPlaylistName

		end if

	end tell

end playQueue

on getPlaylist(playlistId)

	tell application "Music"

		return (first playlist whose id is playlistId)

	end tell

end getPlaylist

on getPlaylistSongs(playlistId)

	tell application "Music"

		set thePlaylist to getPlaylist(playlistId) of me
		set playlistSongs to every track of thePlaylist

	end tell

	return playlistSongs

end getPlaylistSongs

-- retrieves list of songs within the given genre, sorted by artist
on getGenreSongs(genreName)

	tell application "Music"

		set genreSongs to every track of playlist 2 whose genre is genreName

	end tell

	return genreSongs

end getGenreSongs

-- retrieves list of album names for the given artist
on getArtistAlbums(artistName)

    tell application "Music"

        set artistSongs to every track of playlist 2 whose artist is artistName
        set albumNames to {}

        repeat with theSong in artistSongs

            if (album of theSong) is not in albumNames then

                set albumNames to albumNames & (album of theSong)

            end if

        end repeat

    end tell

    return albumNames

end getArtistAlbums

-- retrieves list of songs by the given artist, sorted by album
on getArtistSongs(artistName)

	tell application "Music"

		set artistSongs to every track of playlist 2 whose artist is artistName

	end tell

	return artistSongs

end getArtistSongs

-- retrieves list of songs in the given album
on getAlbumSongs(albumName)

	tell application "Music"

		set albumSongs to every track of playlist 2 whose album is albumName

	end tell

	return albumSongs

end getAlbumSongs

-- retrieves the song with the given ID
on getSong(songId)

	tell application "Music"

		set theSong to first track of playlist 2 whose database ID is songId

	end tell

	return theSong

end getSong

-- retrieves a list of objects or names matching the given query and type
on getResultsFromQuery(query, queryType)

	set evalScript to run script "
	script

		on findResults(query, queryType, resultLimit)

			tell application \"Music\"

				set theSongs to (get every track in playlist 2 whose " & queryType & " starts with query)

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains (space & query) and " & queryType & " does not start with query)

				end if

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains query and " & queryType & " does not start with query and " & queryType & " does not contain (space & query))

				end if

				if length of theSongs is 0 then

					if queryType is \"name\" then

						set theSongs to theSongs & (search playlist 2 for query only songs)

					else if queryType is not \"genre\" then

						set theSongs to theSongs & (search playlist 2 for query only " & queryType & "s)

					end if

				end if

				if queryType is \"name\" then

					if length of theSongs > resultLimit then

						set theSongs to items 1 thru resultLimit of theSongs

					end if

					set theResults to theSongs

				else

					set theResults to {}

					repeat with theSong in theSongs

						if length of theResults is resultLimit then exit repeat

						set theResult to " & queryType & " of theSong

						if theResult is not in theResults then

							set theResults to theResults & theResult

						end if

					end repeat

				end if

			end tell

			return theResults

		end findResults

	end script
	"

	evalScript's findResults(query, queryType, resultLimit)

end getResultsFromQuery

-- returns the given string with leading and trailing whitespace removed
on trimWhitespace(theString)

	-- trim leading whitespace
	repeat while theString begins with space

		if length of theString is 1 then return ""
		set theString to text 2 thru end of theString

	end repeat

	-- trim trailing whitespace
	repeat while theString ends with space

		set theString to text 1 thru ((length of theString) - 1) of theString

	end repeat

	return theString

end trimWhitespace

-- queues the song with the given ID
on queueSong(songId)

	set theSong to getSong(songId)
	queueSongs({theSong})

end queueSong

-- queues all songs belonging to the given album
on queueAlbum(albumName)

	set albumName to decodeFeedbackChars(albumName)
	set albumSongs to getAlbumSongs(albumName)
	queueSongs(albumSongs)

end queueAlbum

-- queues all songs by the given artist
on queueArtist(artistName)

	set artistName to decodeFeedbackChars(artistName)
	set artistSongs to getArtistSongs(artistName)
	queueSongs(artistSongs)

end queueArtist

-- queues all songs within the given genre
on queueGenre(genreName)

	set genreName to decodeFeedbackChars(genreName)
	set genreSongs to getGenreSongs(genreName)
	queueSongs(genreSongs)

end queueGenre

-- queues all songs in the given playlist
on queuePlaylist(playlistId)

	set playlistSongs to getPlaylistSongs(playlistId)
	queueSongs(playlistSongs)

end queuePlaylist

-- parses the given result query to retrieve type and id of item to queue
on parseResultQuery(query)

	set pos to offset of "-" in query
	set theType to text 1 thru (pos - 1) of query
	set theId to text (pos + 1) thru end of query
	return {type:theType, id:theId}

end parseResultQuery

on queue(query)

	set typeAndId to parseResultQuery(query)
	set theType to type of typeAndId
	set theId to id of typeAndId

	createWorkflowPlaylist()

	if theType is "song" then
		queueSong(theId)
	else if theType is "album" then
		queueAlbum(theId)
	else if theType is "artist" then
		queueArtist(theId)
	else if theType is "genre" then
		queueGenre(theId)
	else if theType is "playlist" then
		queuePlaylist(theId)
	else
		log "Unsupported type: " & theType
	end if

end queue

on play(query)

	clearQueue()
	queue(query)
	playQueue()

end play

-- core configuration --

-- configurable options --

-- limit number of songs to improve efficiency
property resultLimit : 15
-- whether or not to retrieve/display album artwork for each result
property albumArtEnabled : true

-- workflow parameters --

-- workflow folders
property libraryFolder : (path to library folder from user domain as text)
property cacheFolder : (libraryFolder & "Caches:")
property alfredWorkflowDataFolder : (cacheFolder & "com.runningwithcrayons.Alfred:Workflow Data:")
property bundleId : "com.calebevans.playsong"
property workflowCacheFolder : (alfredWorkflowDataFolder & bundleId & ":") as text

-- the default icon used for search results without album artwork
property defaultIconName : "resources/icon-noartwork.png"
-- the name of the playlist used by the workflow for playing songs
property workflowPlaylistName : "Alfred Play Song"
-- list of Alfred results
property resultList : {}

-- replaces substring in string with another substring
on replace(replaceThis, replaceWith, theString)

	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to replaceThis
	set strItems to text items of theString
	set AppleScript's text item delimiters to replaceWith
	set newString to strItems as text
	set AppleScript's text item delimiters to oldDelims
	return newString

end replace

-- retrieve the plural/singular form of a quantity based on the given number
on quantifyNumber(theNumber, quantityName, pluralQuantityName)

	if theNumber is 1 then

		set theString to (theNumber as text) & space & quantityName

	else

		set theString to (theNumber as text) & space & pluralQuantityName

	end if

	return theString

end quantifyNumber

-- encodes JSON reserved characters in the given string
on encodeFeedbackChars(theString)

	set theString to replace("\\", "\\\\", theString)
	set theString to replace("\"", "\\\"", theString)
	return theString

end encodeFeedbackChars

-- decodes JSON reserved characters in the given string
on decodeFeedbackChars(theString)

	set theString to replace("\\\\", "\\", theString)
	set theString to replace("\\\"", "\"", theString)
	return theString

end decodeFeedbackChars

-- adds Alfred result to result list
on addResult(theResult)

	copy theResult to the end of resultList

end addResult

-- adds item for "No Results" message
on addNoResultsItem(query, queryType)

	addResult({uid:"no-results", valid:"no", title:"No Results Found", subtitle:("No " & queryType & "s matching '" & query & "'"), icon:defaultIconName})

end addNoResultsItem

on resultListIsFull()

	return (length of resultList is resultLimit)

end resultListIsFull

on resultListIsEmpty()

	return (length of resultList is 0)

end resultListIsFull

-- builds Alfred result item as JSON
on getResultFeedback(theResult)

	-- encode reserved JSON characters
	set resultUid to encodeFeedbackChars(uid of theResult)
	set resultValid to (valid of theResult) as text
	set resultTitle to encodeFeedbackChars(title of theResult)
	set resultSubtitle to encodeFeedbackChars(subtitle of theResult)

	if (icon of theResult) contains ":" then

		set resultIcon to encodeFeedbackChars(POSIX path of icon of theResult)

	else

		set resultIcon to icon of theResult

	end if

	set json to "{"
	set json to json & "\"uid\":\"" & resultUid & "\","
	set json to json & "\"arg\":\"" & resultUid & "\","
	set json to json & "\"valid\":\"" & resultValid & "\","
	set json to json & "\"title\":\"" & resultTitle & "\","
	set json to json & "\"subtitle\":\"" & resultSubtitle & "\","
	set json to json & "\"icon\":{\"path\":\"" & resultIcon & "\"}"
	set json to json & "}"
	return json

end getResultFeedback

-- retrieves JSON document for Alfred results
on getResultListFeedback()

	set json to "{\"items\": ["

	repeat with theResult in resultList

		set json to json & getResultFeedback(theResult)
		set json to json & ","

	end repeat

	-- remove trailing comma after last item
	set json to text 1 thru (length of json - 1) of json
	set json to json & "]}"
	return json

end getResultListFeedback

-- query path to artwork image file cached natively by Music.app in Catalina
on getSongArtworkPath(theSong)

	try

		if albumArtEnabled is false then return defaultIconName

		tell application "Music"

			-- get persistent ID of song and use it to fetch album artwork
			set songId to persistent ID of theSong
			-- the base path to the artwork file (without extension)
			set artworkPath to (do shell script "./resources/get-song-artwork-path.sh" & space & songId & space & defaultIconName)

		end tell

		return artworkPath

	on error errorMessage

		log errorMessage

	end try

end getSongArtworkPath

-- creates album artwork cache
on createWorkflowPlaylist()

	tell application "Music"

		if not (user playlist workflowPlaylistName exists) then

			make new user playlist with properties {name:workflowPlaylistName, shuffle:false}

		end if

	end tell

end createWorkflowPlaylist

on clearQueue()

	tell application "Music"

		if user playlist workflowPlaylistName exists then

			delete tracks of user playlist workflowPlaylistName

		end if

	end tell

end clearQueue

on queueSongs(theSongs)

	tell application "Music"

		repeat with theSong in theSongs

			duplicate theSong to user playlist workflowPlaylistName

		end repeat

	end tell

end queueSongs

on playQueue()

	tell application "Music"

		if number of tracks in user playlist workflowPlaylistName is not 0 then

			play user playlist workflowPlaylistName

		end if

	end tell

end playQueue

on getPlaylist(playlistId)

	tell application "Music"

		return (first playlist whose id is playlistId)

	end tell

end getPlaylist

on getPlaylistSongs(playlistId)

	tell application "Music"

		set thePlaylist to getPlaylist(playlistId) of me
		set playlistSongs to every track of thePlaylist

	end tell

	return playlistSongs

end getPlaylistSongs

-- retrieves list of songs within the given genre, sorted by artist
on getGenreSongs(genreName)

	tell application "Music"

		set genreSongs to every track of playlist 2 whose genre is genreName

	end tell

	return genreSongs

end getGenreSongs

-- retrieves list of album names for the given artist
on getArtistAlbums(artistName)

    tell application "Music"

        set artistSongs to every track of playlist 2 whose artist is artistName
        set albumNames to {}

        repeat with theSong in artistSongs

            if (album of theSong) is not in albumNames then

                set albumNames to albumNames & (album of theSong)

            end if

        end repeat

    end tell

    return albumNames

end getArtistAlbums

-- retrieves list of songs by the given artist, sorted by album
on getArtistSongs(artistName)

	tell application "Music"

		set artistSongs to every track of playlist 2 whose artist is artistName

	end tell

	return artistSongs

end getArtistSongs

-- retrieves list of songs in the given album
on getAlbumSongs(albumName)

	tell application "Music"

		set albumSongs to every track of playlist 2 whose album is albumName

	end tell

	return albumSongs

end getAlbumSongs

-- retrieves the song with the given ID
on getSong(songId)

	tell application "Music"

		set theSong to first track of playlist 2 whose database ID is songId

	end tell

	return theSong

end getSong

-- retrieves a list of objects or names matching the given query and type
on getResultsFromQuery(query, queryType)

	set evalScript to run script "
	script

		on findResults(query, queryType, resultLimit)

			tell application \"Music\"

				set theSongs to (get every track in playlist 2 whose " & queryType & " starts with query)

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains (space & query) and " & queryType & " does not start with query)

				end if

				if length of theSongs < resultLimit then

					set theSongs to theSongs & (get every track in playlist 2 whose " & queryType & " contains query and " & queryType & " does not start with query and " & queryType & " does not contain (space & query))

				end if

				if length of theSongs is 0 then

					if queryType is \"name\" then

						set theSongs to theSongs & (search playlist 2 for query only songs)

					else if queryType is not \"genre\" then

						set theSongs to theSongs & (search playlist 2 for query only " & queryType & "s)

					end if

				end if

				if queryType is \"name\" then

					if length of theSongs > resultLimit then

						set theSongs to items 1 thru resultLimit of theSongs

					end if

					set theResults to theSongs

				else

					set theResults to {}

					repeat with theSong in theSongs

						if length of theResults is resultLimit then exit repeat

						set theResult to " & queryType & " of theSong

						if theResult is not in theResults then

							set theResults to theResults & theResult

						end if

					end repeat

				end if

			end tell

			return theResults

		end findResults

	end script
	"

	evalScript's findResults(query, queryType, resultLimit)

end getResultsFromQuery

-- returns the given string with leading and trailing whitespace removed
on trimWhitespace(theString)

	-- trim leading whitespace
	repeat while theString begins with space

		if length of theString is 1 then return ""
		set theString to text 2 thru end of theString

	end repeat

	-- trim trailing whitespace
	repeat while theString ends with space

		set theString to text 1 thru ((length of theString) - 1) of theString

	end repeat

	return theString

end trimWhitespace

-- queues the song with the given ID
on queueSong(songId)

	set theSong to getSong(songId)
	queueSongs({theSong})

end queueSong

-- queues all songs belonging to the given album
on queueAlbum(albumName)

	set albumName to decodeFeedbackChars(albumName)
	set albumSongs to getAlbumSongs(albumName)
	queueSongs(albumSongs)

end queueAlbum

-- queues all songs by the given artist
on queueArtist(artistName)

	set artistName to decodeFeedbackChars(artistName)
	set artistSongs to getArtistSongs(artistName)
	queueSongs(artistSongs)

end queueArtist

-- queues all songs within the given genre
on queueGenre(genreName)

	set genreName to decodeFeedbackChars(genreName)
	set genreSongs to getGenreSongs(genreName)
	queueSongs(genreSongs)

end queueGenre

-- queues all songs in the given playlist
on queuePlaylist(playlistId)

	set playlistSongs to getPlaylistSongs(playlistId)
	queueSongs(playlistSongs)

end queuePlaylist

-- parses the given result query to retrieve type and id of item to queue
on parseResultQuery(query)

	set pos to offset of "-" in query
	set theType to text 1 thru (pos - 1) of query
	set theId to text (pos + 1) thru end of query
	return {type:theType, id:theId}

end parseResultQuery

on queue(query)

	set typeAndId to parseResultQuery(query)
	set theType to type of typeAndId
	set theId to id of typeAndId

	createWorkflowPlaylist()

	if theType is "song" then
		queueSong(theId)
	else if theType is "album" then
		queueAlbum(theId)
	else if theType is "artist" then
		queueArtist(theId)
	else if theType is "genre" then
		queueGenre(theId)
	else if theType is "playlist" then
		queuePlaylist(theId)
	else
		log "Unsupported type: " & theType
	end if

end queue

on play(query)

	clearQueue()
	queue(query)
	playQueue()

end play


Changed example text for name field to First Last

FasdUAS 1.101.10
k
l Render and Message		& Render and Message

l
+% A rendering and notification service
J A rendering and notification service
l by Axel Villamil" by Axel Villamil
l
l
l
l Get users credentials, Get users credentials
l!"!TN must be exact name, email and phone associated with your iMessage credentials"## must be exact name, email and phone associated with your iMessage credentials $%
$l%&'
&l(
(I)*
.sysodlogaskrTEXT
)m++,,2Enter your iMessage email*-

dtxt
-m..//your@email.com'01
0l
2
2r
34
3n56
51

ttxt
61

rslt
4o	0email178
7l9
9I:;
.sysodlogaskrTEXT
:m<<==DEnter your associated phone number;>

dtxt
>m??@@+1 647 XXXXXXX8AB
AlC
CrDE
DnFG
F1

ttxt
G1

rslt
Eo0phonenumberphoneNumberBHI
Hl#J
JI#KL
.sysodlogaskrTEXT
KmMMNN(Enter your full nameLO

dtxt
OmPPQQFirst LastIRS
Rl$)T
Tr$)UV
Un$'WX
W1%'

ttxt
X1$%

rslt
Vo0fullnamefullNameSYZ
YlZ[\
[l]^] Run rendify.jsx^__  Run rendify.jsx\`a
`labc
bl*4d
dO*4ef
el.3ghi
gl.3jkl
jI.3m
.miscfilenull****
mm./nnoo/Applications/Adobe After Effects CC 2015.3/Scripts/AErendify.jsxk5/ Change depending on path of rendify.jsx scriptlpp^ Change depending on path of rendify.jsx scripth3- Change depending on version of After EffectsiqqZ Change depending on version of After Effects
fm*+rrRFXTCalisMacintosh HDH+Adobe After Effects CC 2015.appӠ@	 Adobe After Effects CC 2015.31RӠxOIYMacintosh HD:Applications:Adobe After Effects CC 2015.3:Adobe After Effects CC 2015.app@Adobe After Effects CC 2015.appMacintosh HDJApplications/Adobe After Effects CC 2015.3/Adobe After Effects CC 2015.app/cst
sltuv
ulwxw&  Read string from jsx error filexyy@ Read string from jsx error filevz{
zl{|}
|l5<~
~r5<
m58X/Users/axelvillamil/Desktop/rendifyError.txt
o
0myfile}
l=H
r=H
I=D
.rdwrread********
o=@
0myfile
o0aenumberAEnumber
l
l+% Checks if jsx render queue is empty J Checks if jsx render queue is empty
l
lI
OI
kO
eO^
nO^
1Y]

pnam
nOY
mUY

icsv
4OU

pres
oST0fullnamefullName
r_f
m_bE:
o0a
rgp
bgl
ogj0a
ojk	0email
o0
appleemail
appleEmail
Zq
Eqx
oqt0aenumberAEnumber
mtw1
I{
.ichtsendnull****
m{~\Your After Effects render queue is complete =

TO
n
4

pres
o0phonenumberphoneNumber
4

icsv
o0
appleemail
appleEmail
mILfez!alisVMacintosh HDH+OIMessages.appOʹ	 Applications1R?OI'Macintosh HD:Applications:Messages.appMessages.appMacintosh HDApplications/Messages.app/
l
l
.aevtoappnull****
.aevtoappnull****
k&07AHRb|+.<?MPrn~}|{zy

dtxt
.sysodlogaskrTEXT

rslt

ttxt	0email0phonenumberphoneNumber0fullnamefullName
.miscfilenull****
0myfile
.rdwrread********0aenumberAEnumber

pres
~
icsv
}
pnam|0a{0
appleemail
appleEmail
z
TO
y.ichtsendnull****lO,EOlO,EOlO,EOjUOaE`O_jE`OaI*a/a,a,EOaE`O_%E`O_aaa*a_/a/lYhUascr
ޭ

FasdUAS 1.101.10
k
l Render and Message		& Render and Message

l
+% A rendering and notification service
J A rendering and notification service
l by Axel Villamil" by Axel Villamil
l
l
l
l Get users credentials, Get users credentials
l!"!TN must be exact name, email and phone associated with your iMessage credentials"## must be exact name, email and phone associated with your iMessage credentials $%
$l%&'
&l(
(I)*
.sysodlogaskrTEXT
)m++,,2Enter your imessage email*-

dtxt
-m..//your@email.com'01
0l
2
2r
34
3n56
51

ttxt
61

rslt
4o	0email178
7l9
9I:;
.sysodlogaskrTEXT
:m<<==.Enter your phone number;>

dtxt
>m??@@+1 647 XXXXXXX8AB
AlC
CrDE
DnFG
F1

ttxt
G1

rslt
Eo0phonenumberphoneNumberBHI
Hl#J
JI#KL
.sysodlogaskrTEXT
KmMMNN(Enter your full nameLO

dtxt
OmPPQQFrank OceanIRS
Rl$)T
Tr$)UV
Un$'WX
W1%'

ttxt
X1$%

rslt
Vo0fullnamefullNameSYZ
YlZ[\
[l]^] Run rendify.jsx^__  Run rendify.jsx\`a
`labc
bl*4d
dO*4ef
el.3ghi
gl.3jkl
jI.3m
.miscfilenull****
mm./nnoo/Applications/Adobe After Effects CC 2015.3/Scripts/AErendify.jsxk5/ Change depending on path of rendify.jsx scriptlpp^ Change depending on path of rendify.jsx scripth3- Change depending on version of After EffectsiqqZ Change depending on version of After Effects
fm*+rrRFXTCalisMacintosh HDH+Adobe After Effects CC 2015.appӠ@	 Adobe After Effects CC 2015.31RӠxOIYMacintosh HD:Applications:Adobe After Effects CC 2015.3:Adobe After Effects CC 2015.app@Adobe After Effects CC 2015.appMacintosh HDJApplications/Adobe After Effects CC 2015.3/Adobe After Effects CC 2015.app/cst
sltuv
ulwxw&  Read string from jsx error filexyy@ Read string from jsx error filevz{
zl{|}
|l5<~
~r5<
m58X/Users/axelvillamil/Desktop/rendifyError.txt
o
0myfile}
l=H
r=H
I=D
.rdwrread********
o=@
0myfile
o0aenumberAEnumber
l
l+% Checks if jsx render queue is empty J Checks if jsx render queue is empty
l
lI
OI
kO
eO^
nO^
1Y]

pnam
nOY
mUY

icsv
4OU

pres
oST0fullnamefullName
r_f
m_bE:
o0a
rgp
bgl
ogj0a
ojk	0email
o0
appleemail
appleEmail
Zq
Eqx
oqt0aenumberAEnumber
mtw1
I{
.ichtsendnull****
m{~\Your After Effects render queue is complete =

TO
n
4

pres
o0phonenumberphoneNumber
4

icsv
o0
appleemail
appleEmail
mILfez!alisVMacintosh HDH+OIMessages.appOʹ	 Applications1R?OI'Macintosh HD:Applications:Messages.appMessages.appMacintosh HDApplications/Messages.app/
l
l
.aevtoappnull****
.aevtoappnull****
k&07AHRb|+.<?MPrn~}|{zy

dtxt
.sysodlogaskrTEXT

rslt

ttxt	0email0phonenumberphoneNumber0fullnamefullName
.miscfilenull****
0myfile
.rdwrread********0aenumberAEnumber

pres
~
icsv
}
pnam|0a{0
appleemail
appleEmail
z
TO
y.ichtsendnull****lO,EOlO,EOlO,EOjUOaE`O_jE`OaI*a/a,a,EOaE`O_%E`O_aaa*a_/a/lYhUascr
ޭ


Huge overhaul, basically allowed direct opening of Jarvis from the applescript.

(*Instead of using the spotlight app, this opens a new terminal directly*)

tell application "Terminal"
	activate

	(*names currentTab  need to find a more elegant method*)
	set currentTab to do script ""

	(*sets up the script for dictation*)
	tell application "System Events" to keystroke "./jarvis.sh \"\""
	tell application "System Events" to key code 123

	(*opens up speech-to-text*)
	tell application "System Events" to key code 63
	tell application "System Events" to key code 63
	delay 4

	(*presses "enter" on DictationIM*)
	tell application "System Events" to tell process "DictationIM"
		click button 1
	end tell
	delay 1.2

	(*presses "enter" in the terminal*)
	tell application "System Events" to key code 36

	(*closes the terminal when process is completed*)
	set mainID to id of front window
	set toggle to 1
	delay 0.1
	set thetimeout to 100
	repeat until toggle ≥ thetimeout
		if busy of currentTab is false then
			close (every window whose id = mainID)
			set toggle to thetimeout
		end if
		set toggle to (toggle + 1)
		delay 0.1
	end repeat

end tell

tell application "System Events" to key code 49 using {command down}
delay 0.3
tell application "System Events" to keystroke "terminal"
delay 0.1
tell application "System Events" to key code 36
delay 0.3
tell application "System Events" to keystroke "./jarvis.sh \"\""
tell application "System Events" to key code 123

tell application "System Events" to key code 63
tell application "System Events" to key code 63
delay 4
tell application "System Events" to tell process "DictationIM"
	click button 1
end tell
delay 1.2
tell application "System Events" to key code 36


Updated AppleScript

Updated AppleScript

tell application "Visual Studio Code" to activate
tell application "System Events"
	# Start
	repeat 20 times
		keystroke "\\" using {shift down, control down, option down, command down}
	end repeat
	# Base
	keystroke "`" using control down
  delay 0.25
	keystroke "gulp build --fresh && gulp watch"
	# Demo
	keystroke "n" using command down
  delay 0.25
	keystroke "cd demo"
	keystroke return
  delay 0.1
  keystroke "meteor run"
	# End
	keystroke "[" using {shift down, control down, option down, command down}
	keystroke "`" using control down
end tell

tell application "Visual Studio Code" to activate
tell application "System Events"
	# Start
	repeat 20 times
		keystroke "\\" using {shift down, control down, option down, command down}
	end repeat
	# Base
	keystroke "`" using control down
	keystroke "clear && pwd"
	keystroke return
	# Demo
	keystroke "n" using command down
	keystroke "cd demo"
	keystroke return
	keystroke "clear && pwd"
	keystroke return
	# End
	keystroke "[" using {shift down, control down, option down, command down}
	keystroke "`" using control down
end tell