How to link/call an actual shell script saved within an Applescript app

applescriptbashcallcommand linegeolocation

What's the correct syntax in the Applescript below to make this app run by double clicking on it rather than how it runs now by just running the Applescript in the AS script editor?

The Shell script is located at:

ToggleHidden.app/Contents/Resources/Scripts/toggle.sh

And it is set to execute by all. (I did chmod a+x toggle.sh)


Applescript

set bottomRoot to (path to me) as alias

 tell application "System Events"
 set myPath to (POSIX path of container of bottomRoot)

end tell

set scriptPath to quoted form of (myPath & "/toggle.sh")

do shell script scriptPath

Shell script

#!/bin/sh

STATUS=`defaults read com.apple.finder AppleShowAllFiles

if [ $STATUS == TRUE ];

then

defaults write com.apple.finder AppleShowAllFiles FALSE

else

defaults write com.apple.finder AppleShowAllFiles TRUE

fi

killall Finder

sleep .5

open .

Best Answer

You could also just use do shell script:

do shell script "killall Finder
[[ $(defaults read com.apple.finder AppleShowAllFiles) = 1 ]] && b=false || b=true
defaults write com.apple.finder AppleShowAllFiles -bool $b
sleep .5
open -a Finder"