x11vnc Copy-and-Paste…

To prevent typos and OS line break-type kerfuffles, I typically copy files instead of copy-pasting any files’ contents across VNC sessions.

Somehow, I came across wanting to just copy-paste a file via a VNC session, which used to work ye long ago… But it just was not happening…

Diving into the ‘net for answers, I came across autocutsel… Although some places stated to use xstartup files, as I was using x11vnc, this was not possible, so I simply ended up creating a services file (with a dependency on the x11vnc service):

  • assuming x11vnc had been installed as a service (refer here), install autocutsel:
    • apt install autocutsel
  • create the /etc/systemd/system/autocutsel.service service file:
    [Unit]
    Description=Start autocutsel at startup.
    After=multi-user.target display-manager.service
    Requires=x11vnc.service
    
    [Service]
    Type=simple
    User=lightdm
    Environment="DISPLAY=:0"
    ExecStart=/usr/bin/autocutsel -s PRIMARY
    ExecStop=killall autocutsel
    Restart=always
    RestartSec=3
    
    [Install]
    WantedBy=multi-user.target graphical.target
  • reload systemd configuration:
    • systemctl daemon-reload
  • enable x11vnc service:
    • systemctl enable autocutsel
  • reboot

The catch? Having to specify the $DISPLAY

But… Somehow, everything I tried for x11vnc was pretty much borked – mainly only one-way (from Linux x11vnc to Windows VNC client).

It then struck me that the VNC client has a part to play – some Windows-based VNC clients had the “enable bidirectional copy-and-paste” option on the client (assuming the VNC server supported this).

After some trial-and-error:

Windows Client License x11vnc Copy-Paste Works?
RealVNC Viewer Commercial (viewer is freeware) Bidirectional
TightVNC Viewer Opensource Bidirectional
RemoteRipple Opensource Bidirectional
UltraVNC Viewer Opensource Unidirectionl (x11vnc host > Windows client)
TigerVNC Viewer Opensource Unidirectionl (x11vnc host > Windows client)

There were some other sites stating to also “play around” with the -selection [ CLIPBOARD | PRIMARY ], but I started off with PRIMARY and since it worked for me, I did not try it without (i.e. CLIPBOARD by default)…

Leave a Reply