Shortcut for "Sync Grids"?

I generally switch the “Sync grids” option on and off multiple times a day. Is there a way to perform this action via hotkey?

One idea is to bind a hotkey (or have an icon) to execute the following shell script command:

defaults write com.binaryage.TotalSpaces2 lockGridsTogether -bool YES

and this to turn it off

defaults write com.binaryage.TotalSpaces2 lockGridsTogether -bool NO

I’m not certain if TotalSpaces2 will react instantly to setting this by the command line, let me know if it doesn’t and I’ll look at how to fix it.

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