AppleSpacesSwitchOnActivate is represented by the second button on print below

enter image description here

In the code below, I get the current value and after I change. This can be tested in terminal with

defaults read -g AppleSpacesSwitchOnActivate

// getting value of AppleSpacesSwitchOnActivate
let switchOnActivate = CFPreferencesCopyAppValue("AppleSpacesSwitchOnActivate" as CFString, ".GlobalPreferences" as CFString)
print(switchOnActivate as! Bool)

// setting value of AppleSpacesSwitchOnActivate to false
CFPreferencesSetAppValue("AppleSpacesSwitchOnActivate" as CFString, false as CFBoolean, ".GlobalPreferences" as CFString)
CFPreferencesAppSynchronize(".GlobalPreferences" as CFString)

Basically, the value AppleSpacesSwitchOnActivate is changed, but the change is not effective until killall Dock.

Is there some way to update dock preferences plist without killall Dock?

  • What's wrong with killing the dock process? You can do that in Swift as well.
    – DarkDust
    Nov 4, 2021 at 7:14
  • When dock process is killed, all minimized windows are exposed. I want to evit this behavior
    – a_kira
    Nov 4, 2021 at 13:59


You must log in to answer this question.

Browse other questions tagged .