如何在 macOS 上的终端中切换切换(连续性)?

bra*_*njp 3 terminal command-line macos

有没有办法从命令行启用/禁用切换设置?

目前,我使用的是 macOS Mojave 10.14.3,我知道我可以通过转到“设置”>“常规”>“允许切换”来切换它 - 但正在寻找替代方法。

设置中的切换开关

slh*_*hck 6

以下命令应关闭切换:

\n\n
sudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityAdvertisingAllowed -bool no\nsudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityReceivingAllowed -bool no\n
Run Code Online (Sandbox Code Playgroud)\n\n

要再次打开:

\n\n
sudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityAdvertisingAllowed -bool yes\nsudo -u $(whoami) defaults write "$HOME/Library/Preferences/ByHost/com.apple.coreservices.useractivityd.plist" ActivityReceivingAllowed -bool yes\n
Run Code Online (Sandbox Code Playgroud)\n\n

来源:jamf.com \xe2\x80\x93 请注意,我尚未验证这些命令,但 OP 声称它们正在工作。

\n


小智 5

@slhck 的答案可以简化为:

在:

defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool yes
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool yes
Run Code Online (Sandbox Code Playgroud)

离开:

defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool no
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool no
Run Code Online (Sandbox Code Playgroud)