Comments (6)
This is not a bug, since it was never the intended behavior for the synchronization (which is meant only to sync items in specific tabs).
I've created a command that would help with the clipboard synchronization: Top Item to Clipboard (see README.md for details on how to add the command)
Let me know how that works.
from copyq.
Thank you very much for the explanation. I was obviously not aware of that and this does seem to work. I now only need to figure out why the CopyQ tab is not being updated until I activate/click CopyQ. I suspect that SyncThing is waiting for local filesystem access to retrieve vs the source system pushing an update to initiate the transfer since it's based on file node activity.
from copyq.
@hluk I've noticed a side effect of this new functionality that I'm not sure how to deal with. I use Clop to optimize images automatically, which is very useful, but I've found that with this functionality enabled now with CopyQ it will strip out some of the clip/pasteboard contents on macOS and only allow the textual file location to be available and not the image itself.
As far as I understand it, macOS has multiple encodings that can be available per paste/clip and subsequently some of this data is somehow stripped out by this action.
Additionally, I really like Pastebot and use it on macOS systems, but its synchronization mechanism via iCloud is horrible. The reason I've turned to CopyQ is to facilitate clipboard sharing between both various macOS, Windows and Linux systems I use regularly. I would still like to use Pasteboard, but what I have noticed is that also now enabling this action causes multiple copies of entries to frequently show up in Pasteboard, which I think is an evidence of being related to the issue that Clop is also facing.
Do you perceive of a way to improve this situation or to revise the command script to overcome this / these problem(s)?
Nevermind, this and various permutations still didn't work:
EDIT: I may have figured out a solution, please let me know what you think. The following implements consideration for MIME types in the command:
[Command]
Command="
// This script ensures all MIME types are preserved when syncing the top clipboard item,
// particularly useful for maintaining rich data like images processed by Clop.
// Preserve the original onItemsAdded function
var onItemsAdded_ = onItemsAdded;
onItemsAdded = function() {
// Call the original function to maintain existing behavior
onItemsAdded_();
// Early return if we're not in the clipboard tab
if (selectedTab() !== config('clipboard_tab')) return;
var sel = ItemSelection().current();
const topItemIndex = sel.rows().indexOf(0);
// Early return if there's no top item
if (topItemIndex === -1) return;
const item = sel.itemAtIndex(topItemIndex);
var mimeData = {};
// Get all MIME types for the item
var mimeTypes = itemMimeTypes(topItemIndex);
// Build the mimeData object
mimeTypes.forEach(function(mimeType) {
// Only copy non-empty data to avoid unnecessary empty fields
var data = item[mimeType];
if (data && data.length > 0) {
mimeData[mimeType] = data;
}
});
// Only perform the copy operation if we have data to copy
if (Object.keys(mimeData).length > 0) {
copy(mimeData);
} else {
// Not sure if this will do anything, but anyway:
print('Warning: No valid data found in top clipboard item');
}
}"
Icon=
IsScript=true
Name=Enhanced Top Item to Clipboard with MIME Types
Seems that somehow we have to consider MIME type data, but not sure how to do that in context of CopyQ and macOS' pasteboard.
from copyq.
Not sure if it would help, but you can also override onItemsChanged
so that the clipboard changes when the first item changes:
[Command]
Command="
var onItemsAdded_ = onItemsAdded;
onItemsAdded = function() {
onItemsAdded_();
syncClipboard();
}
var onItemsChanged_ = onItemsChanged;
onItemsChanged = function() {
onItemsChanged_();
syncClipboard();
}
function syncClipboard() {
if (selectedTab() != config('clipboard_tab'))
return;
var sel = ItemSelection().current();
const i = sel.rows().indexOf(0);
if (i == -1)
return;
const item = sel.itemAtIndex(i);
copy(mimeItems, pack(item));
}"
Icon=
IsScript=true
Name=Top Item to Clipboard
from copyq.
One downside is that the refresh of synchronized tabs is delayed (optimized so it does not happen unnecessarily) and is triggered mainly when the tab is displayed again. This would postpone adding new items and synchronizing the clipboard.
from copyq.
I will drop the Top Item to Clipboard command from the command repository since it is very unreliable due to the sync-refresh delay.
An alternative could be to write clipboard content to a special file to the shared folder whenever the clipboard changes, and monitor the file (regularly or with a utility).
from copyq.
Related Issues (20)
- The text and background colors are the same, resulting in unclear display HOT 1
- command with Win key does not run HOT 1
- Unwanted letters HOT 1
- Can you make it so that this will work when I double click an item to paste it in the text editor in Blender
- Multiple texts cannot be merged HOT 2
- CopyQ on Pop!_OS 2024 - Wayland
- Desktop todo stickies base on clipboard HOT 1
- copy with mouse selection issue in windows
- Custom Notification HOT 1
- Display html without storing it HOT 2
- App crashes everytime at startup on MacOS even after doing steps in README HOT 2
- Where is the backup settings? HOT 3
- Wayland dependencies on Xorg-only HOT 1
- Compile CopyQ for Windows ARM64 HOT 1
- hide clipboard content HOT 1
- Create new item .md and choose folder HOT 1
- CopyQ menu() blink and crashing #macOS
- CopyQ doesn't work with firefox HOT 3
- Flickering, shaking text, images HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from copyq.