Inconsistent copy and paste behaviour. Is there a fix?
I've encountered what I can best describe as "unpredictable" behaviour of the "clipboard". But in its own way, it actually is "predictable"", as it is not an X bug, as such.
It largely results from different X applications using different X features in different ways...
But it doesn't really help to know that it isn't "actually" a bug. because it feels like a bug!
There is a list (below) of what I've found / tested.
Is there some way (a daemon?), which irons out all these wrinkles? I'd prefer something that doesn't sit in the panel.
The X / Ubuntu clipboard is potentially awesome, because of its 2/3 levels ability, but is a bit annoying because of the inconsistent implementations...
I've been trying to understand why the copy/paste thing didn't always do what I expected... It's amazing what you can learn when you read the info docs :) ... But a question can hit the target faster.
The main issue seems to come about when the source application is shut down, and you try to access "clipboard" data which came from that application.
X GUI applications have two major copy/paste methods (modes).
Mode NAME Text Copy method Text Paste method
---------- --------------------- -------------------
PRIMARY currently selected mouse middle-click
CLIPBOARD Control+C selection Control+V
I've tested the behaviour of the selection modes for a few different X applications: gvim
, gedit
, firefox
, and gnome-terminal
.
NB:
* All pasting was done into gedit
* The gedit source was from another (root) instance)
* I've tried a couple of "managers", parcelite
and pastie
, but I can't see any point in comparing them, because neither address the problem. That is, normally expected copy / paste keyboard actions are "inconsistent"
+ --------------------------------------------- + ------------------------------------------- + ------------
| Modes used in the source Application | Availability upon CLOSING the Applicaton | Application
+ --------------------------------------------- + ------------------------------------------- + ------------
| --- No manager ---
| PRIMARY only, no CLIPBOARD Copy/Cut used: | PRIMARY Empty! (previous)CLIPBOARD ok | (all tested)
| | -- |
| CLIPBOARD as last action (implicit PRIMARY): | PRIMARY Empty! CLIPBOARD Empty! | gvim
| | PRIMARY Empty! CLIPBOARD ok | gedit, gnome-terminal
| | PRIMARY Empty! CLIPBOARD Empty! | firefox
| | -- |
| PRIMARY as last action, preceded by CLIPBOARD | PRIMARY ok CLIPBOARD Empty! | gvim
| | PRIMARY Empty! CLIPBOARD ok | gedit, gnome-terminal
| | PRIMARY Empty! CLIPBOARD Empty! | firefox
| --- Manager: parcelite ---
| PRIMARY only, no CLIPBOARD Copy/Cut used: | PRIMARY ok (previous)CLIPBOARD ok | (all tested)
| | -- |
| CLIPBOARD as last action (implicit PRIMARY): | PRIMARY ok CLIPBOARD Empty! | gvim, firefox
| | PRIMARY ok CLIPBOARD ok | gedit, gnome-terminal
| | -- |
| PRIMARY as last action, preceded by CLIPBOARD | PRIMARY ok CLIPBOARD Empty! | gvim, firefox
| | PRIMARY ok CLIPBOARD ok | gedit, gnome-terminal
|
+ --------------------------------------------- + ------------------------------------------- + ------------
Solution 1:
That is a known limitation of X, please refer to this article of the official wiki:
https://wiki.ubuntu.com/ClipboardPersistence
The main issue remains the inconsistency between applications that may use different approach to clipboard handling.
In the wiki article there are listed working and not working application ( also the only workaround proposed is to install parcelite as clipboard manager )
Solution 2:
Try autocutsel, in repos - it syncs the two. You have to add it to .bashrc or startup aps, or just start it manually (it is command line, not gui) but it has always worked well for me. You do have to remember to switch the focus to the field (if browser, for example) or document (gedit, kate, gvim...) before pasting or it will appear to not work.