Open VNC virt-viewer (.vv) files on macOS

I tried to use virt-viewer from homebrew but it didn’t work properly. Instead I decided to write an Automator App that reads the contents of the .vv file and opens the macOS built-in VNC viewer.

Create a new Automator Application, and add the “Run Shell Script” action and choose to pass input as arguments. Select bash as the shell and enter the following code:

/usr/bin/env python3 <<'EOF' - "$@"
import configparser
import sys
import os
import urllib.parse

config = configparser.ConfigParser()[1])
password = urllib.parse.quote(config['virt-viewer']['password'].encode('utf8'), safe='')
os.system("open vnc://:"+ password + "@" + config['virt-viewer']['host'] + ":" + config['virt-viewer']['port'])

Save the action under /Applications. In Finder, open the .vv file with this new app and choose to always open this file extension with it. Now when you double click on a .vv file in Finder, it should open the VNC console.