#!/usr/bin/env bash

# Example output of defaults read:
#NSGlobalDomain GSAppKitUserBundles '(
#    "/usr/GNUstep/System/Library/Bundles/Camaelon.themeEngine",
#    "/usr/GNUstep/System/Library/Bundles/EtoileMenus.bundle",
#    "/usr/GNUstep/System/Library/Bundles/EtoileBehavior.bundle"
#)'

bundle='"/usr/GNUstep/System/Library/Bundles/Camaelon.themeEngine"'

temp_file=`mktemp`
echo `defaults read NSGlobalDomain GSAppKitUserBundles` > ${temp_file}

if ! grep -q ${bundle} ${temp_file}; then
	echo "Adding bundle to GSAppKitUserBundles..."
	sed -i "s# )#, ${bundle} )#" ${temp_file}
	defaults write < ${temp_file}
else
	echo "Bundle already present in GSAppKitUserBundles"
fi

unlink ${temp_file}
