Toggle hot corners with a script

Solution 1:

wvous-tl-corner is the top-left hot corner. Use ‘tl’, ‘tr’, ‘bl’, ‘br’ for each corner respectively, and use -int 0 to disable that corner.

To find the integer for activating the hot corner of choice, make the change in System Preferences, then use defaults read com.apple.dock wvous-tl-corner.

Don't forget to restart the Dock too after writing using defaults: killall Dock.

Solution 2:

Riffing on the excellent answer from @grg, you can loop over each corner like this:

#!/usr/bin/env bash

set -eu

# Turn off hot-corners
for corner in tl tr br bl;
  do
    defaults write com.apple.dock "wvous-$corner-corner" -int 0
  done
killall Dock