Skip to content

Commit

Permalink
Add "Top Item to Clipboard" command
Browse files Browse the repository at this point in the history
See also: hluk/CopyQ#2834
  • Loading branch information
hluk committed Sep 5, 2024
1 parent 1a73979 commit 03c8f93
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ Resets last clipboard text (or X11 selection) if it's cleared.

Show main window after application starts.

### [Top Item to Clipboard](top-item-to-clipboard.ini)

Whenever a new top item is added to the clipboard tab, it is also copied to
the system clipboard.

This can be useful if **Synchronization** is enabled with a CopyQ instance
running on different machine. In such case, this command ensures that system
clipboard contents are also synchronized (if the clipboard is automatically
inserted to the tab as the first item).

### [Wayland Support](wayland-support.ini)

Adds support for some features under Wayland compositors in KDE, Sway, Hyprland
Expand Down
20 changes: 20 additions & 0 deletions Scripts/top-item-to-clipboard.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[Command]
Command="
var onItemsAdded_ = onItemsAdded;
onItemsAdded = function() {
onItemsAdded_();
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

0 comments on commit 03c8f93

Please sign in to comment.