Display computers and servers advertising screen sharing or VNC services advertised with the
_rfb._tcp. service type. This is advertised by MacOS machines with Screen Sharing enabled in the Sharing panel of System Preferences.
This version of a template for
_rfb._tcp. differs from BonjourLauncher.recipes.VNC in that it uses a function which examines the text records for the service to determine which launcher to use for the chosen server: because RealVNC uses an encryption scheme that is not recognized by the macOS Screen Sharing application, if a text record indicating that RealVNC is in use is detected, an alternate launcher is used.
The template can be added to your BonjourLauncer with
spoon.BonjourLauncher:addRecipes("VNC_RealVNC_Alternate") after the spoon has loaded, and is defined as follows:
image = hs.image.imageFromAppBundle("com.apple.ScreenSharing"),
label = "VNC",
type = "_rfb._tcp.",
text = "%name%",
subText = "vnc://%hostname%:%port%",
url = "vnc://%hostname%:%port%", -- used in fn when RealVNC not set ; see below
cmd = "open -a \"VNC Viewer\" --args %hostname%:%port%", -- used in fn when RealVNC set; see below
fn = function(svc, choice)
local tr = svc:txtRecord()
if tr and tr.RealVNC then
fn is defined, so it will be invoked in favor of
cmd by the BonjourLauncer spoon when a VNC service is selected; however, the second argument to the function invoked will include all key-value pairs with string values from the template, so the function can utilizes the
cmd keys based on its own logic to determine which applies.
This variant was developed to address the fact that the macOS Screen Sharing application does not recognize the encryption used by the RealVNC implemntataion found in the Raspbian distribution installed on most Raspberry Pi computers. By adding text record to the Avahi advertisement from the Raspberry Pi, we can determine whether or not to utilize the built in screen sharing app or launch the RealVNC client to view the specified service.
See also BonjourLauncher.recipes.VNC for a simpler implementation if you are only connecting to other Mac computers or if none of your servers require RealVNC's specific viewer application.
To create the advertisement on the Raspbian installation which includes the text record entry we need to make this template work, install Avahi on your Raspbian machine and save the following as
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">