hluk / copyq-commands Goto Github PK
View Code? Open in Web Editor NEWUseful commands for CopyQ clipboard manager.
Useful commands for CopyQ clipboard manager.
following link is 404 on readme
https://github.com/hluk/CopyQ/blob/master/src/scriptable/README.md
I'm creating an action to perform some transformations on text/html
clips. I want to paste the transformed HTML, or create a new clip from it.
I am able to get the original HTML data with str(input())
and then transform it, but I am not able to paste the result as text/html, nor to create a new clip of type text/html from the transformed text.
Web developers often handle unformatted Json data, all in one line. Often hard to read, when the amount of data increases. In the past, I wrote a Lua script for SciTE to format Json. With CopyQ, the task is trivial.
Code:
[Command]
Name=Paste formatted Json
Command="
copyq:
var text = str(input())
try {
var json = JSON.parse(text)
// Remplace '\\t' with a number to indent
// with this amount of spaces
text = JSON.stringify(json, null, '\\t')
} catch (e) {
}
copy(text)
paste()
"
Input=text/plain
InMenu=true
HideWindow=true
Icon=\xf121
Description:
Pastes selected Json text as a formatted Json text.
If not Json, just pastes the text as is.
Found a bug on snippets.ini where when you select the first snippet it doesn't pastes and throws no error.
Looking into the source it's the "|| abort()" on line 64, it activates the abort because the zero index evaluates to false.
Since dialog() returns "undefined" when cancelling the dialog, the snippet var should be evaluated as:
if (typeof snippet === "undefined")
abort()
wayland-support.ini does not work with menu
its working if i select "paste as plain text"
for testing i add serverLog in sendShortcut
it does not log when im selecting but it log when i do "paste as plain text"
i think global.paste does not run when we do direct paste from menu
Hi,
CopyQ is now working perfect for me; it's the best tool!
I just have one issue:
Is there any way to auto remove trailing space when copy/pasting:
For example, "copyq " would be pasted as "copyq" (without the ending space)
Would really appreciate it!
In my environments, copyq paste selected item to clipboard
rather than primary
after enter
, which results shift-insert
not work, but ctrl-shift-v
works. Is there something wrong config in my copyq? Appreciate for your work!
Hi, I am very much a layperson when it comes to programming, so apologies for my ignorance/inability to help myself. I started using the command Copy Clipboard to Window Tabs, but then I wanted to blacklist passwords copied in my password manager. I found this approach, but one issue intersecting with the Window Tabs command is that it deletes the pw only from &clipboard -- not also "Windows/Mozilla Firefox" or "Windows/Bitwarden". I realize it's probably just a matter of duplicating the code and replacing "Clipboard" with the names of the two windows I'm also trying to delete copy's from, but I'm not sure which instances I need to replace and which I need to keep. Could you please advise?
This is about https://github.com/hluk/copyq-commands/blob/master/Automatic/import-commands-after-copied.ini
When importing a command by manually copy-pasting - everything works.
When importing a command via the (awesome) utility script (link above), the Advanced / Match Items / Content and Window fields are populated with the values below:
/\/(?:)\//
This causes (most) commands to not function properly until properly removing the bad content.
If the script includes matching, then the escaping is off, and for any \
a \\
is populated.
no errors but
i checked items and clipboard. => no changes.
Hi,
The README doesn't explain how to use or install the provided scripts.
Can you please add this information to the README?
Thank you.
I just wanted a simple clipboard manager, how did I end up with an IDE called CopyQ??? π
I am really not able to figure out whether the syntax of copyq is pearl, js or something custom. Unfortunately I'm not good at either.
Well anywas, could you please paste a code snippet here, as a reply, for clearning (deleting or removing) all tabs, items and contents with in-menu button and global shortcut.
Thank you.
Feature Request to simplify complete Syncing.
For people who have many clips to save and organize Topically or 0-Z.
Greetings, I've been trying to come up with a global command to play a sound when pasting to windows. I can't get it to work, exceptions keep getting thrown at me. Is it allowed to ask for guidance here?
This is my "Play Sound on Copy" command, which plays a sound and copies the selected text to the clipboard and copyq ...
[Command]
Name=Play Sound on Copy
Command="
powershell:
$mydocuments=[environment]::getfolderpath(\"mydocuments\");(New-Object Media.SoundPlayer \"$mydocuments\\MMT\\CopyQ\\sounds\\WoodClickUp.wav\").PlaySync()"
Automatic=true
Icon=\xf028
Log says: CopyQ Note [2021-10-22 12:53:19.713] <Client-23948>: Command "Play Sound on Copy": Finished in 1424 ms
And this is my "Play Sound on Paste" command, which doesn't work. No sound is produced, and nothing is pasted.
[Command]
Name=Play Sound on Paste
Command="
powershell:
$mydocuments=[environment]::getfolderpath(\"mydocuments\");(New-Object Media.SoundPlayer \"$mydocuments\\MMT\\CopyQ\\sounds\\WoodClickDown.wav\").PlaySync()
copyq: paste()"
IsGlobalShortcut=true
Icon=\xf028
GlobalShortcut=ctrl+v
Log says:
CopyQ Note [2021-10-22 12:53:29.908] <Server-31728>: Command βPlay Sound on Pasteβ
CopyQ Note [2021-10-22 12:53:29.908] <Server-31728>: Exit code: 1
CopyQ Note [2021-10-22 12:53:29.908] <Server-31728>: 1. powershell $mydocuments=[environment]::getfolderpath("mydocuments");(New-Object Media.SoundPlayer "$mydocuments\MMT\CopyQ\sounds\WoodClickDown.wav").PlaySync()
CopyQ Note [2021-10-22 12:53:29.908] <Server-31728>: 2. copyq: paste()
Please tell me what I'm doing wrong - and thank you so much.
Hello hluk
Hello all
I would love to have the wayland-support.ini script working. It's not pasting automatically to the front most application.
Love this app so much, and if this would work I would be the happiest man on earth.
Ydotool is up and running:
$ ydotool type 123
123β
$ 123
I tried the following terminal commands to troubleshoot:
$ copyq currentWindowTitle
copyq currentWindowT ~
$ copyq paste
Could it beβ
$ Could it be
$ copyq copy
^CScriptError: Failed to start ydotool
--- backtrace ---
eval(arguments[0])()
--- end backtrace ---
After I execute copyq copy
my keyboard is messed up, all the keys are on the wrong place. After entering copyq copy
again everything goes to normal again
Could it be that it's because NixOS has non standard path to applications?:
> which ydotool
/run/current-system/sw/bin/ydotool
Version, OS and Environment
(Get details from copyq version command if possible.)
Application Version 7.1.0
OS Linux > NixOS
Hyperland window manager
Is it possible to detect if the same text is copied to the clipboard twice in a row?
I would like to run certains actions, such as opening an url in the browser, if it is copied twice. This is more convenient than eg. assigning a global shortcut as I can just press Ctrl-C twice.
The problem is that CopyQ automatically removes duplicates which is normally wanted. So the second time the clip is copied, nothing happens.
Is it possible to run an action at a point before CopyQ checks if the item already exists?
I'm doing a lot of database word where I'm passing some dynamic sql.
CASE WHEN [t].[VALUE] = 'Foo' THEN NULL ELSE 'Bar' END
and I often need to reverse it from ''
to '
as well.
I have tried it this way
copyq:
function modifyText(text)
{
// TODO: Modify text here!
return text.replace("'", "''")
}
if (!copy())
abort()
var text = str(clipboard())
var newText = modifyText(text)
if (text == newText)
abort();
copy(newText)
paste()
and it only replaces the very first '
with ''
. It never gets them both. Any help appreciated.
Hi.
I do not find the option to list all tabs and jump to a certain one per click.
Is there such script, command?
Where could i post a wish? :)
thx
I was hoping you could help with a solution for the following script you wrote:
https://github.com/hluk/copyq-commands/blob/master/Global/copy-a-secret.ini
I'm using BitWarden and I frequently use the "copy password to clipboard" button on my password manager, rendering the copy secret hotkey ineffective. Would there be a way to set a hotkey that I would hold, and then click the "copy password to clipboard" button so the password would be ignored?
Any help would be appreciated!
when running join selected items with a lot of items, it will fail with error execve Argument list too long
and no item will be created but selected items are deleted
issue happened on 300 items of urls
[Command]
Command="
copyq add %1"
Icon=\xf066
InMenu=true
Name=Join Selected Items
Remove=true
Shortcut=space
CopyQ Clipboard Manager v3.13.0
Qt: 5.14.2
Compiler: GCC
Arch: x86_64-little_endian-lp64
OS: Ubuntu 21.10
item succesfully created
or
item not succesfully created but selected items are not deleted
execve Argument list too long
this is similar issue to hluk/CopyQ#1573 but the solution is to rewrite the command
i am not familiar enough with javascript or bash to rewrite the command, and also there is no example to get selected items to python
is it possible to add option to not remove selected item when command error ?
I would like to ignore text like passwords copied from specific windows. Therefore I understood a built in command is available but obviously not working in Hyprland. In Hyprland hyprctl clients
shows all active windows, their class, title and so on, below an example of Firefox running and showing this GitHub page. However it seems copyq is considering some other values for the window name, as the filter criteria ^$
matches all windows I tried so far. Is there any way I can compare my regex against one of the values from below?
...
Window 590ed6fd0700 -> Issues Β· hluk/copyq-commands β Mozilla Firefox:
mapped: 1
hidden: 0
at: 647,36
size: 611,742
workspace: 3 (3)
floating: 0
monitor: 0
class: firefox
title: Issues Β· hluk/copyq-commands β Mozilla Firefox
initialClass: firefox
initialTitle: Mozilla Firefox
pid: 80075
xwayland: 0
pinned: 0
fullscreen: 0
fullscreenmode: 0
fakefullscreen: 0
grouped: 0
swallowing: 0
focusHistoryID: 1
...
Creating this issue after hluk/CopyQ#2557.
I'm running Arch with Hyprland compositor. After enabling wayland support script everything runs smooth, except paste behavior ONLY in terminal emulators - instead of the clipboard content, it inserts something else. It seems to be related to the paste shortcut, which wayland support script sends and which seems to be Shift+Insert. As it is not paste shortcut by default in most terminal emulators - the issue occurs.
Some extra lines should be added to README.md file, going to do it by myself.
i using ubuntu
Hi
Trying modify-selected-text.ini and getting the following error:
Exception in "Template: Modify..."
Failed to copy to clipboard
Exit code: 4
1. copyq:
2. function modifyText(text)
I would like to remove end of line replacing EOL with space.
I would like to give you this one Liner, my first copyQ oneLiner.
This will help completion build symfony consolne commands.
if you use a tab named symfonyBinConsole backup it first !!!
clear; copyq removetab symfonyBinConsole; copyq show symfonyBinConsole; rm ./symfonyBinConsole2copyQ.sh; ~/symfony/example/bin/console > symfonyBinConsole2copyQ.sh; sed -ri 's/\s*([^ ]+)(.*)/copyq tab symfonyBinConsole add "\1 # \2"/' symfonyBinConsole2copyQ.sh ; chmod +x ./symfonyBinConsole2copyQ.sh ; ./symfonyBinConsole2copyQ.sh
BTW: First i tried https://github.com/bamarni/symfony-console-autocomplete but not works for me.
I am getting current clip using var clip = str(clipboard())
and working on that. But in long run I come across same clip which is flooding my work with duplicates.
So is there any method to know that my current clip
exist in my old clips??
Thanks.
Hi.
Top app! :)
What about a command to search and replace specific text in an opened and edited item ?
Or globally for all items in the actual tab or all tabs?
thx :)
Note [2020-06-08 02:39:07.057] : --- backtrace ---
Note [2020-06-08 02:39:07.057] : importCommandsFromUrl(url = 'https://github.com/hluk/copyq-commands/blob/master/Automatic/big-data-tab.ini') at β...β:23
Note [2020-06-08 02:39:07.057] : () at β...β:31
Note [2020-06-08 02:39:07.057] : () at β...β:4
Note [2020-06-08 02:39:07.057] : --- end backtrace ---
Note [2020-06-08 02:40:11.855] : ScriptError: Exception in command: Failed to fetch commands.
Note [2020-06-08 02:40:11.855] : Status code: undefined
Note [2020-06-08 02:40:11.855] : Error: TLS initialization failed
I'm using a CopyQ command from the repository to get the URL with Title and Icon (https://github.com/hluk/copyq-commands/blob/master/Automatic/tab-for-urls-with-title-and-icon.ini) and it gets the Title and the URL perfectly, but often it does not get the Icon. For example, it doesn't get an icon for http://www.woot.com or http://www.bgr.com. Second, when it does get an Icon, there is always an extra grey square in front of it. Is there a way to remove the grey square? See the attached screenshot for examples.
Thanks,
Rich
Hello,
is it possible to apply Display Command to items in the tray menu?
I'd like to mask all items starting with some prefix.
E.g. items starting with 'S$' should be displayed in the tray menu as 'Masked Password'.
The below Command works as expected in the main CopyQ window, but it doesn't in the tray menu.
copyq:
const textData = str(data(mimeText));
const passwordPrefix = 'S$';
if (textData.startsWith(passwordPrefix)) {
setData('text/plain', 'Masked Password');
}
Cheers
Jarek
I use copyq on macOS and have a RayCast extension where I can search for emojis and paste them quickly. The problem is every time I paste an emoji, it copies it into my clipboard, causing unnecessary clutter. I'm looking to make an automatic command that checks newly added clipboard content for entries that contain only one emoji and nothing else (ex: 'π§πΌβπ»').
Can someone assist me in making this command? Thanks!
Pictures below:
Would be nice to have a script to test the commands.
For each command the script would:
COPYQ_SESSION=command-tests
,COPYQ_SETTINGS_PATH=config/path/
(available in development version, not in v3.5.0),<command>.js
script.Travis could install latest CopyQ version and run the script.
Hi,
I'm using this command https://github.com/hluk/copyq-commands/blob/master/Automatic/move-images-to-other-tab.ini
to copy (not move) images to the "Images" tab.
I don't know how to programmatically do it, so I installed the command and in "Advanced" tab, I set the "Copy to tab: clipboard":
It did the job (although I'd like to know how to alter the command for no manual setup)
I tried removing the command and starting over again and same result. When I disable the command the mouse selection works fine.
CopyQ Clipboard Manager 7.1.0
Qt: 6.5.2
Compiler: GCC
Arch: x86_64-little_endian-lp64
OS: Ubuntu 23.04
X11
N.B. I did exactly the same with this command to copy URLs in a tab and the mouse works just fine!
https://github.com/hluk/copyq-commands/blob/master/Automatic/tab-for-urls-with-title-and-icon.ini
Hello, I wasn't sure where to ask this question so posting here, but happy to post it somewhere else just let me know.
I wanted to use the "Save image to a file" command (see https://copyq.readthedocs.io/en/latest/images.html#save-image-to-a-file ) but I couldn't figure out how to do it.
Is there an explanation somewhere?
Show main window under mouse cursor but don't close when unfocused even if it is set to close in the settings
I was just passing by for another reason, and I happened to notice in #89 you mentioned something. I didn't want to hijack that issue so I thought I should make another one.
The default copy() override for Wayland Support uses the following command:
ydotool key 29:1 46:1 46:0 29:0
This sends Ctrl+C shortcut so if run it in terminal it will send interrupt signal on the command line (the Ctrl+C shortcut - see the
^C
in your output) which causes theydotool
not to send final key release events to the system so you end up with Ctrl in "pressed" state.
When I saw this, it occurred to me - what if we were to use
ydotool key 29:1 110:1 110:0 29:0
To send ctrl+ins as the replacement copy command? I guess it probably should work for most things, and also, it would be terminal-friendly? But I have a feeling you will already have considered this and have chosen ctrl+c for a good reason I haven't thought of yet π Anyway, I thought maybe this might be helpful.
I am trying to export the top 10 clips from the clipboard into a text file that can be read by MATRIC (an android dashboard for Windows). Here's what I've got so far but I'm missing something on how to reference the correct items.
var filePath = 'E:\\VSDev\\matric\\copyq\\clipboard.txt'
function storeClipboard() {
var f = File(filePath)
if ( !f.openWriteOnly() ) {
popup(
'Failed saving clipboard',
'Cannot open file: ' + filePath
+ '\n' + f.errorString())
return;
}
selectItems(0,1,2,3,4,5,6,7,8,9)
for(i=0;i<=9;i++) {
var item = selectedItemData(i)
//var text = JSON.stringify(item)
var text = str(item[mimeText])
if (text.length>15) {
linedata = i+1 + ': ' + text.substring(1,15) + '...\n'
} else {
linedata = i+1 + ': ' + text + '\n'
}
f.write(linedata)
}
f.close()
}
var onClipboardChanged_ = global.onClipboardChanged
global.onClipboardChanged = function() {
onClipboardChanged_()
storeClipboard()
}
The goal output is something like:
1: somecopied text
2: some really long ...
3: //image// <=note I have not added code for this yet
4: 123456
etc to 10
First of all, thanks for developing CopyQ! By now, it saved me countless of hours of work, all the while looking incredibly pretty (the UI and UX are top notch).
In my daily usage I often find myself copying a lot of lines at once, such that a single item fills up the entire CopyQ window as seen in the image below.
How would I go about creating an Automatic script to move these long items to a separate tab (perhaps named &long
)? I took a look at the Scrpting API documentation but haven't gotten any ideas from it. So far, I have a hunch that a modified version of the Big Data Script may do the trick.
Thanks in advance!
Hi hluk,
Is it possible to capture a date and time stamp for each clipboard entry?
Thanks.
Hi.
Where is Command: Merge and Delete ?
copyq:
add(input())
I can not find it anymore.
It should not jump automatically to the top of the tab.
Can you please create scrip for X shortcut key copy new item to specific tab. or option to disable CTRL+C pasted in Copyq But rather other shortcut key will pasted in Copyq.
Apologies, but I searched and could not resolve this query - which is probably an embarrassingly obvious in some way that I missed.
In both my LNX (MX) and Win11 installations I cannot (for the life of me) get files to Sync to either my external cloud OR an internal directory.
I have tried multiple TAB and destination FOLDER variants. (See Image)
I have tried Closing and Re-opening the App.
So, how about this ... WHAT is the command (method) of FORCING the Sync operation to occur? I just want to see one single successful Sync either locally or in a Cloud folder.
I have not found the Sync user info page to be instructive in this regard. (Sorry - this section is dishearteningly thin.)
So ... HOW does a User get a simple, first-time, Sync of Items under a Tab name?
And then, can someone provide a Step x Step, explanation of the precise SYNTAX to specify for TAB NAME and PATH in Preferences? Are there prefix or suffix characters I have neglected to include??
Another thing not clarified in the Support Docs is IF or HOW recursive "Tab" DIRs are or could be included. OR if all sub-Tabs must be specified as separate entries. (If not, would be an obvious Feature Request).
With apologies for being a "Dummy" if I missed something in the Config that is obvious - but I really need to Sync the exact Clips for 2 machines which will read an external cloud drive containing the CPQ target for Items copied.
Upon success, I would leap for joy.
Hiya,
I'm pretty keen to try out the Big Data Tab since my clipboard needs to have many items, and for many months now, that's not been a problem, but lately, it's starting to freeze up when I search, obviously I have a few items in there that are too big and causing a problem.
This command seems like it could help, but it only acts when new items are added, and I still have the existing 'big data' items in my clipboard. Is there some command I could run, to search the entire list, and move those items into the big data tab, all at once?
Perhaps this is an FR, to add such a command to run when the big data tab command is added? I'm not sure.
Thanks for any help or advice you could give :)
Please when i press shortcuts to copy item 0 or item 1 command for example
i need ever open copyQ window to change clipboard value ?
is possible for only press shortcuts and change clipboard value ?
Hi,
For the command "Remove Carriage Return, Line Feed and Multiple Space Then Paste",
can we also please remove trailing and leading spaces.
For example, "copyq " would be pasted as "copyq" (without the leading space)
Thank you π π₯
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.