Hi,
Our fleet has just jumped from Catalina to Monterey and our users are struggling to locate the screen mirroring "Show in menu Bar" tickbox.
Ideally I would just like a script to enable this or our users.
I have tried
defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist ScreenMirroring -int 18
but it doesn't seem to work.
weirdly sound and bluetooth work though which are controlled inside the same plist.
e.g: defaults write ~/Library/Preferences/ByHost/com.apple.controlcenter.plist Sound -int 18
anyone got any ideas how the ScreenMirroring preference can be set via terminal script?
Cheers,
ES
Best answer by scottb
@elliots :
I found this in the MacAdmins slack...credit to @nstrauss - noting it's "per user":
#!/bin/zsh
logged_in_user=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name 😕😕 && ! /loginwindow/ { print $3 }')
user_home=$(dscl . -read /users/$logged_in_user NFSHomeDirectory | cut -d " " -f 2)
sudo -u "$logged_in_user" /usr/bin/defaults write "$user_home"/Library/Preferences/ByHost/com.apple.controlcenter.plist ScreenMirroring -int 18
sudo -u "$logged_in_user" /usr/bin/defaults write "$user_home"/Library/Preferences/com.apple.airplay.plist showInMenuBarIfPresent -bool true
sudo killall "ControlCenter"Works here in macOS 12.2 beta I'm running, so give it a shot....