Finding the New Theme Install Location in FileStorm

Many theme developers use update installers to issue their theme updates. Until recently this has been a flawless system. When Realmac Software released RapidWeaver 5 they changed the default double-click install location for themes. This has effectively killed the usefulness of update installers on themes installed with RapidWeaver 5 since we’ve all built our installers with the assumption that our themes would be found in ~/Library/Application Support/RapidWeaver/.

All of us use FileStorm to build our installers and thankfully FileStorm allows us to run scripts at various stages of the update process. So I quickly wrote a pair of shell scripts today for use with FileStorm.

The Launch Script

The first is used as a launch script, executed before the installer does its stuff. Since I don’t know where the theme has been installed (or no longer want to assume), I need to find that theme. Then I need to move it to a known location so that the installer can perform the required updates.

The script looks like this (don’t cut and paste, use source):

themeName="$1".rwtheme
rwDir=~/Library/Application\ Support/RapidWeaver
themePathNew="$rwDir"/"$themeName"

if [ ! -d "$themePathNew" ]
    then
        themePathOrig=`find "$rwDir" -name "$themeName"`
        themeDirOrig=`dirname "$themePathOrig"`
        mv "$themePathOrig" "$rwDir"

        echo $themeName " was moved from " $themeDirOrig > "$rwDir"/_installer_wasMoved.text
        echo $themePathNew > "$rwDir"/_installer_themePathNew.text
        echo $themeDirOrig > "$rwDir"/_installer_themeDirOrig.text
fi

I save this as a shell script and call from the Installer Property Inspector under the advanced menu > Installer Scripts > Launch Script. I can then use the themes name in the Parameter field which will then get passed into the script.

launch script as seen in property inspector

The Exit Script

The second script is an exit script that gets executed after the installer is done installing. It needs to move the theme back to where it came from in the first place (since I am being a responsible citizens).

The script looks like this (don’t cut and paste, use source):

if [ ~/Library/Application\ Support/RapidWeaver/_installer_wasMoved.text ]
    then
        rwDir=~/Library/Application\ Support/RapidWeaver
        themePathNew=$(cat "$rwDir"/_installer_themePathNew.text)
        themeDirOrig=$(cat "$rwDir"/_installer_themeDirOrig.text)

        mv "$themePathNew" "$themeDirOrig"
        rm "$rwDir"/_installer_wasMoved.text
        rm "$rwDir"/_installer_themePathNew.text
        rm "$rwDir"/_installer_themeDirOrig.text
fi

I save this as a shell script and call from the Installer Property Inspector under the advanced menu > Installer Scripts > Exit Script. I leave the Parameter field blank as none are needed.

exit script as seen in property inspector

I hope this helps other theme developers work out this little hiccup that we now all face.

Comments are closed.