如何在 macOS 上的終端​​機中切換切換(連續性)?

如何在 macOS 上的終端​​機中切換切換(連續性)?

有沒有辦法從命令列啟用/停用切換設定?

目前,我使用的是 macOS Mojave 10.14.3,我知道我可以透過前往「設定」>「常規」>「允許切換」來切換它 - 但正在尋找替代方法。

設定中的切換開關

答案1

以下命令應關閉切換:

sudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityAdvertisingAllowed -bool no
sudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityReceivingAllowed -bool no

要再次打開:

sudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityAdvertisingAllowed -bool yes
sudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityReceivingAllowed -bool yes

來源:jamf.com– 請注意,我尚未驗證這些命令,但 OP 聲稱它們正在工作。

答案2

@slhck 的回答可以簡化為:

在:

defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool yes
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool yes

離開:

defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool no
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool no

相關內容