Open the Bluetooth pane in System Preferences. Click the Advanced button. Uncheck the boxes marked
Open Bluetooth Setup Assistant...
Disable the Bluetooth Setup Assistant.
Open System Preferences
Click Bluetooth
Click Advanced…
Uncheck Open Bluetooth Setup Assistant at startup if no keyboard is detected
Uncheck Open Bluetooth Setup Assistant at startup if no mouse or trackpad is detected
Click "OK"
tell application "System Events" to key code 144 using command down
my add_item_to_dock(choose file of type {"APPL"} with prompt "Choose an application to add to the Dock:")
on add_item_to_dock(item_path)
try
get item_path as alias -- you need a POSIX path so this coerces the path in case it's an HFS path, alias, file ref, etc.
set item_path to POSIX path of item_path
end try
try
tell application "Dock" to quit
end try
do shell script "defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" & item_path & "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'"
try
tell application "Dock" to activate
end try
end add_item_to_dock
mkdir MyIcon.iconset
sips -z 16 16 Icon1024.png --out MyIcon.iconset/icon_16x16.png
sips -z 32 32 Icon1024.png --out MyIcon.iconset/[email protected]
sips -z 32 32 Icon1024.png --out MyIcon.iconset/icon_32x32.png
sips -z 64 64 Icon1024.png --out MyIcon.iconset/[email protected]
sips -z 128 128 Icon1024.png --out MyIcon.iconset/icon_128x128.png
sips -z 256 256 Icon1024.png --out MyIcon.iconset/[email protected]
sips -z 256 256 Icon1024.png --out MyIcon.iconset/icon_256x256.png
sips -z 512 512 Icon1024.png --out MyIcon.iconset/[email protected]
sips -z 512 512 Icon1024.png --out MyIcon.iconset/icon_512x512.png
cp Icon1024.png MyIcon.iconset/[email protected]
iconutil -c icns MyIcon.iconset
rm -R MyIcon.iconset
+---------------------+--------------------+--------------+
| filename | resolution, pixels | density, PPI |
+---------------------+--------------------+--------------+
| icon_16x16.png | 16x16 | 72 |
| [email protected] | 32x32 | 144 |
| icon_32x32.png | 32x32 | 72 |
| [email protected] | 64x64 | 144 |
| icon_128x128.png | 128x128 | 72 |
| [email protected] | 256x256 | 144 |
| icon_256x256.png | 256x256 | 72 |
| [email protected] | 512x512 | 144 |
| icon_512x512.png | 512x512 | 72 |
| [email protected] | 1024x1024 | 144 |
+---------------------+--------------------+--------------+
Target Display Mode via SSH
Slightly modified from http://aaronrutley.com/target-display-mode-via-ssh/
-
Move all files to ~/tdm/
-
brew install blueutil
-
Set up permissions:
- System Preferences > Sharing > Remote Login ☑
- You will also need to give some apps accessibility access (Security & Privacy > Privacy > Accessibility). Can add it after you run the code.
-
create alias (by pasting into ~/.bash_profile)
- username: the user you're logging into iMac
- hostname: the iMac's name (run
hostname
in iMac's terminal to get it) - after adding the below code,
source ~/.bash_profile
to take effect
# imac target display mode function alias imac='function _imac(){ if [ $1 = "start" ]; then echo "--- MacBook Bluetooth on..."; blueutil -p 1; sleep 1; echo "--- Connecting to iMac via ssh..."; ssh -2 -p 22 [email protected] sh ~/tdm/start.sh; fi if [ $1 = "end" ]; then echo "--- MacBook Bluetooth off..."; blueutil -p 0; sleep 1; echo "--- Connecting to iMac via ssh..."; ssh -2 -p 22 [email protected] sh ~/tdm/end.sh; fi if [ $1 = "shutdown" ]; then echo "--- MacBook Bluetooth off..."; blueutil -p 0; echo "--- Shutting down remote imac....."; ssh -2 -p 22 [email protected] sh ~/tdm/shutdown.sh; fi if [ $1 = "ssh" ]; then echo "--- Connecting via ssh....."; ssh [email protected]; fi };_imac'
-
SSH into iMac without password:
# when you issue the following command you'll be asked some questions, keep hitting enter until done. ssh-keygen scp ~/.ssh/id_rsa.pub [email protected]:~/ ssh [email protected] mkdir .ssh # skip this if you already have the folder cat id_rsa.pub >> ~/.ssh/authorized_keys rm -f id_rsa.pub exit
imac start
: start TDM
imac end
: end TDM
imac shutdown
imac ssh
: ssh into iMac
https://medium.com/@gutofoletto/how-to-share-your-imac-keyboard-on-target-display-mode-abfaf10a7992
#!/usr/bin/env bash
# Disable BT on remote machine and enable it on local machine, so KB/Mouse reconnect to local machine.
#ensure local bluetooth is off
blueutil off
#disable imac bluetooth
ssh [email protected] '/usr/local/bin/blueutil off'
#enable local bluetooth
blueutil on
#!/usr/bin/env bash
# Disable BT on local machine and enable it on remote machine, so KB/Mouse reconnect to remote machine.
#ensure local bluetooth is off
blueutil off
#enable imac bluetooth
ssh [email protected] '/usr/local/bin/blueutil on'