10

Using st with dwm, depending on the way I select text (e.g. mouse vs keyboard), and where the text is (e.g. document body vs address bar), copying text from firefox and pasting it into st does not always work.

Are there two different clipboards?

Is there a way to unify them?

2
  • Do you copy with ctrl-c or are you just relying on text-highlighting to copy?
    – drs
    Jun 9, 2014 at 16:21
  • This question and the comments there may be relevant: superuser.com/questions/140944/…
    – njsg
    Oct 11, 2014 at 9:11

3 Answers 3

9

In a sense, yes there are two different clipboards (though X11 calls them "selections", and only one of the selections is called “the clipboard”).

In all likelihood, you are thinking of the Primary Selection (an understandable mistake considering that it functions much more like one on Linux distros than it does under Windows or Mac—though, for the record, the same keyboard shortcuts can typically be used to interact with the Primary Selection under Windows and Mac as they are under Linux).

The clipboard is typically controlled via the Ctrl+{c,v} key bindings for Copy and Paste (respectively). The Primary Selection, on the other hand, has several means of interaction. With the mouse, selecting anything automatically places it in the Primary Selection. Then, one can typically middle-click to Paste from it. One can also use the keyboard: {Ctrl,Shift}+Insert may be used for Copy and Paste (again, respectively) from/to the Primary Selection.

Oddly, it seems X's clipboard is not supported by every application. And, though it may seem unfortunate, there is no way to unify the Primary Selection and the Clipboard. However, there are two solutions for you.

  1. Use the Primary Selection
    It is almost universally available and (at least, it my humble opinion) is a fair bit more flexible.

  2. Use an alternative clipboard manager
    There are plenty of third-party clipboard managers out there which offer far more powerful functionality than the built-in.

Just for example, you could use xcmenu or xclip. There are, however, more alternatives than I can count.


A while after writing this answer, I stumbled upon a clipboard manager called clipit. Among other features that can be quite handy, clipit offers the ability to synchronize the Primary Selection and the X Clipboard. This is functionally equivalent to unifying the two selections and has been really nice to have; I imagine it is exactly what you are looking for.

1
  • To clarify right now, it's not working in either copy and paste, and i'm not even using wayland either.
    – Owl
    Apr 13, 2022 at 13:34
3

I had this issue with Firefox + uxterm/xterm in FreeBSD. I am not sure if this is related to not using a desktop manager (I am using MWM).

The best solution I have found to this problem is to use:

autocutsel -fork -selection CLIPBOARD
autocutsel -fork -selection PRIMARY

as part of your .xinitrc

Then whenever you use CLIPBOARD or PRIMARY everything is synced, and you can copy (CONTROL+C) from Firefox into an xterm (middle click or SHIFT+INSERT).

Another useful tool to see what is going on is xcb.

Both autocutsel and xcb are classic X11 tools and are usually available in Linux distributions and FreeBSD.

1
  • I tried this but having everything that was selected be copied to the clipboard was maddening. What I did instead was switch to a different terminal program, one that would paste from the CLIPBOARD rather than the PRIMARY. Apr 6, 2023 at 17:54
0

I don't use st, but I have information that might be helpful to a general audience. My LXTerminal with default settings uses Ctrl+Shift+{c,v} for copy and paste, respectively. Using Shift is useful because Ctrl+c is needed to send the signal SIGINT.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .