How can I stop spaces from switching automatically?
Stop Spaces from switching spaces due to an app coming to the foreground:

defaults write com.apple.Dock workspaces-auto-swoosh -bool NO &amp;&amp; killall Dock


Or via the GUI: System Prefs &gt; Spaces and then uncheck the checkbox at the bottom: "When switching to an application, switch to a space with open windows for the application"

Stop (slow down) Spaces from switching spaces if your mouse presses against the edge of the desktop:

defaults write com.apple.dock workspaces-edge-delay -float 60 &amp;&amp; killall Dock