Skip to content

Option to use CLIPBOARD selection instead of PRIMARY for paste #167

@coreypenford

Description

@coreypenford

$ cssh -v
Version: 4.16

Issue

In modern environments, specifically some modern Linux Desktop Environments and WSL2 (WSLg) that use Wayland, the system clipboard synchronizes to the X11 CLIPBOARD selection, not the PRIMARY selection.

Currently, clusterssh appears to hardcode the paste operation to use the PRIMARY selection.

This means when copying text from the environment that is populating only the CLIPBOARD selection, you are unable to then paste it into the clusterssh. You will receive a "got empty paste event" message, or alternatively an older PRIMARY entry if it exists would paste, causing confusion.

The FAQ regarding pasting into the console (https://github.com/duncs/clusterssh/wiki/Frequently-Asked-Questions-(FAQ)#pasting-into-the-console-does-not-work) suggests "adding *selectToClipboard: true to the /etc/X11/app-defaults/XTerm"

This only tells xterm to use CLIPBOARD for the selection mechanism. This does enable pasting from xterm selections --> to the other environment, but not the other way around. CLIPBOARD does not populate from other environments or applications with this option enabled.

Possible Fix

A configuration option in .clusterssh/config (e.g., paste_selection_source=CLIPBOARD) or a runtime toggle that tells the Perl-Tk Console window to request the CLIPBOARD selection instead of PRIMARY.

As far as I can tell, this likely involves changing the SelectionGet call in the code at 'lib/App/ClusterSSH/Window/Tk.pm' to accept a configurable selection type.

https://rainbow.ldeo.columbia.edu/documentation/tkperl/selection.htm

https://metacpan.org/dist/Tk/view/pod/selection.pod

Another option that would avoid another config value, is to just try catching PRIMARY first, and then fallback to catching CLIPBOARD. Only if both are empty would you then worry about an empty paste event.

Workaround

While trying to figure this out, I found a workaround

Program that runs in the background and synchronizes the PRIMARY and CLIPBOARD selections. Therefore resolving the issue

Would prefer not to have another program running continuously just to overcome the hard-coding inside this program though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions