Thanks, something like this works perfectly!
if [ $(defaults read com.binaryage.TotalSpaces2 lockGridsTogether) -eq 0 ]
then
defaults write com.binaryage.TotalSpaces2 lockGridsTogether 1
osascript -e 'display notification "Grids are locked together." with title "TotalSpaces Locking"'
else
defaults write com.binaryage.TotalSpaces2 lockGridsTogether 0
osascript -e 'display notification "Grids are unlocked." with title "TotalSpaces Locking"'
fi