Skip to main content

Hey All,



I'm trying to run a command that will allow me to add the screen lock to touchbar.



I've been using the following command.



defaults write com.apple.controlstrip MiniCustomized -array-add com.apple.system.screen-lock
killall ControlStrip


However when the command runs the touch bar refreshes and everyone on my touch bar goes away and the only shortcut is the screen lock



I want to add the screen lock shortcut to the furtherest right position next to the touch ID sensor.



Some info:
Computer is running 10.14.6



Any help would be appreciated.

#!/bin/bash

# Get the Username of the currently logged user
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
echo $loggedInUser

##Set control strip for user
#full
sudo -u $loggedInUser rm ~/Library/Preferences/com.apple.controlstrip.plist
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.group.brightness
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.mission-control
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.launchpad
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.group.keyboard-brightness
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.group.media
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.group.volume
sudo -u $loggedInUser defaults write com.apple.controlstrip FullCustomized -array-add com.apple.system.screen-lock
#mini
sudo -u $loggedInUser defaults write com.apple.controlstrip MiniCustomized -array-add com.apple.system.mute
sudo -u $loggedInUser defaults write com.apple.controlstrip MiniCustomized -array-add com.apple.system.volume
sudo -u $loggedInUser defaults write com.apple.controlstrip MiniCustomized -array-add com.apple.system.brightness
sudo -u $loggedInUser defaults write com.apple.controlstrip MiniCustomized -array-add com.apple.system.screen-lock
killall ControlStrip

thanks @TrH This is exactly what I was looking for.


How would I create the plist itself. Is there a command I need to run in terminal.


Reply