Spice viewer for macOS

So RemoteViewer doesn’t seem to support spice+unix, but it does support spice, i.e. on tcp. Incus is only providing spice+unix. We can use socat to forward a local tcp port to the unix socket:

socat TCP-LISTEN:20000,reuseaddr,fork "UNIX-CLIENT:/Users/USERNAME/Library/Application Support/incus/sockets/XXX.spice"

and then connect to spice://localhost:20000 in RemoteViewer. Tested with RemoteViewer 0.5.7.

Works here too, thank you.

RemoteViewer 0.5.7 binary was released in 2013 and is Intel-only. So it would be good if someone rebuilds it (in which case, adding spice+unix might be an option)

I found in the source there is a feature for configuring a custom spice client and passing the dynamically chosen socket name:

                if preferredSpiceCmd != "" {
                        // preferredSpiceCmd takes a string where the SOCKET keyword is replaced with the path to the SPICE socket.
                        cmdSlice, err := shellquote.Split(strings.ReplaceAll(preferredSpiceCmd, "SOCKET", socket))
                        if err != nil {
                                return err
                        }

This includes the spice+unix:// prefix, so you need a wrapper script to strip that off. I wrote this:

#!/bin/bash -eux
socket="$(echo "$1" | sed -e 's#^spice[+]unix://##' -e 's#%20# #g')"
echo "SOCKET: $socket"
socat TCP-LISTEN:20000,fork "UNIX-CLIENT:$socket" </dev/null &
sleep 1
open -a /Applications/RemoteViewer.app --args spice://localhost:20000
echo "Hit ctrl-C when done"
wait %1

and invoke it from ~/Library/Application\ Support/incus/config.yml:

defaults:
  console_spice_command: "/Users/brian/bin/spice-socat-wrapper SOCKET"

It would be better if socat could assign the port dynamically, but I didn’t see how to do that.

Still, for occasional use, this should do the job.