dns-sd -B _rfb._tcp
returns the "Instance Name" of the device. The hostname however is discovered by running dns-sd -L "INSTANCE_NAME_HERE" _rfb._tcp
. Sometimes instance names and hostnames are not the same. In my case the instance name didn't have the (2)
at the end but my hostname was suffixed with -2
.
In order to fix this, escape_hostname
should be replaced with a command that would run dns-sd -L
on the $name
variable.
I'd submit a PR myself but I have resolved the name mismatch in my case. Also, I'm not sure how to nest the subshell kill
s without killing the parent subshell (e.g. ((sleep 0.1; kill -13 0) &
within a ((sleep 0.1; kill -13 0) &
).
Here was my progress though:
function resolve_hostname {
tail -1 <((sleep 0.1; kill -13 0) & dns-sd -L "$@" _rfb._tcp) | cut -d' ' -f8)
}
Perhaps a separate script would make this work?