I’m using the following command to screen share with a MacBook that is sleeping.
open "vnc://joel@192.168.0.25:5900"
If the machine is asleep you can use the wakeonlan
command to wake it up. You’ll need to install that first with brew install wakeonlan
. Then you can use the following commands together.
wakeonlan AE:FF:5C:FF:A7:FF --ip=192.168.0.25
open "vnc://user@192.168.0.25:5900"
The above wakeonlan
command needs both the mac address and the IP address of the machine you want to connect to.
When you open a connection to the sleeping Mac it will ask you if you want to use Standard or High Performance mode. You can also add a ?quality=high
parameter to the end of the URI to specify one of those options. The options are high
or standard
.
Bringing it all together, I’ve got an alias in my ~/.zshrc
file that connects me to my other Mac using these commands. Typing air
will wake up the machine, wait a second, then connect me to the other Mac using screen sharing. Here’s the full alias.
alias air="wakeonlan AE:FF:5C:FF:A7:FF --ip=192.168.0.25;sleep 1;open \"vnc://joel@192.168.0.25:5900/?quality=high\""
Written by Joel Dare on February 13, 2025.
Get a monthly digest of what I'm up to.