-
Notifications
You must be signed in to change notification settings - Fork 441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cycle items and paste with single hotkey #1948
Comments
Would be great if implemented! |
Sounds quite handy. The functionality can be added to CopyQ with the following command (here is how to add the command to CopyQ): [Command]
Command="
copyq:
// Show/focus the main window if not focused,
// otherwise cycle through items and paste selected
// when the shortcut is released.
if (focused()) {
const sel = ItemSelection().current();
const rows = sel.rows();
if (rows.length > 0) {
selectItems(rows[0] + 1);
} else {
selectItems(0);
}
} else {
show();
// Wait for shortcut modifiers to be released
// or the main window to lose focus.
while (focused() && queryKeyboardModifiers().length > 0) {
sleep(20);
}
if (focused()) {
copy();
hide();
paste();
selectItems(0);
}
}"
GlobalShortcut="ctrl+;"
Icon=\xf1b8
InMenu=true
IsGlobalShortcut=true
Name=Cycle Items |
Hi @hluk! Many thanks to have a look on this :) I've been trying it and I found a couple problems with the script.
Would it be possible you help me to achieve (1) and to understand/debug (2)? Side question, if this finally works fine, do you think it could be added as default command in copyq as "Show main window/cycle items" behaviour? Clarifications
Thank you! 😃 |
The following command should hopefully work as you describe: [Command]
Command="
copyq:
// Show/focus the main window if not focused,
// otherwise cycle through items and paste selected
// when the shortcut is released.
const selectedRowOption = 'cycleItemsSelectedRow'
if (focused()) {
const sel = ItemSelection().current();
const rows = sel.rows();
const row = rows.length > 0 ? rows[0] + 1 : 0;
settings(selectedRowOption, row)
selectItems(row);
} else {
settings(selectedRowOption, 0)
show();
// Wait for shortcut modifiers to be released.
while (queryKeyboardModifiers().length > 0) {
sleep(20);
}
const row = settings(selectedRowOption)
if (row != 0) {
select(row)
hide()
paste()
}
}"
GlobalShortcut="ctrl+;"
Icon=\xf1b8
InMenu=true
IsGlobalShortcut=true
Name=Cycle Items |
That is AWESOME! 👏👏👏 I'm closing, thanks a lot! |
This is now available in the command repository: https://github.com/hluk/copyq-commands/tree/master/Global#cycle-items |
This is very useful. Thank you. I have 1 issue and 2 requests: The issue is that often I get a notification stating The first request is making it wrap around to the first item after the last item. The second request may be quite challenging or maybe even impossible. How about another version in which, when reaching the last item, pressing the shortcut key again moves up one item in the list. For example, let's say we have the following items in the list:
If you hold down the |
I fixed the command so it wraps the selection around: This is now available in the command repository: https://github.com/hluk/copyq-commands/tree/master/Global#cycle-items @Gitoffthelawn Your other idea with back-and-forth selection would be possible using another option for the current selection direction: [Command]
Command="
copyq:
// Pops up the main window (if the shortcut is pressed once), cycles through items
// (if the shortcut is pressed again) and pastes selected item when the shortcut
// is released.
const selectedRowOption = 'cycleItemsSelectedRow'
const selectedTabOption = 'cycleItemsSelectedTab'
const selectDirection = 'cycleItemsSelectDirection'
if (focused()) {
const sel = ItemSelection().current();
const rows = sel.rows();
var direction = Number(settings(selectDirection))
var row = rows.length > 0 ? (rows[0] + direction) : 0;
if (row < 0 || row >= length()) {
direction = -direction
settings(selectDirection, direction)
row = rows[0] + direction
}
settings(selectedRowOption, row)
settings(selectedTabOption, selectedTab())
selectItems(row);
} else {
settings(selectedRowOption, -1)
settings(selectDirection, 1)
show();
// Wait for shortcut modifiers to be released.
while (queryKeyboardModifiers().length > 0) {
sleep(20);
}
const row = settings(selectedRowOption)
if (row != -1) {
tab(settings(selectedTabOption))
select(row)
hide()
paste()
}
}"
GlobalShortcut="ctrl+;"
Icon=\xf1b8
InMenu=true
IsGlobalShortcut=true
Name=Cycle Items |
Thanks so much Lukas! I look forward to trying what you created. BTW, any idea why the original will often display a notification stating |
Guessing it copied empty data (from an out-of-builds item index). |
This deserves its own place in CopyQ's manual. the custom command neatly replicates how Ditto on Windows handles with clipboard cycling (Alt-Tab switcher like cycling) and it's one of the small QoL details I missed most on Linux. |
I'm totally delighted with this feature <3 Using it for months now and super happy. So thanks again for your so quick reply with the command @hluk I hope many others enjoy/found it as well =) |
Is your feature request related to a problem? Please describe.
No, it is more related to the user experience, and to improve usability for a quite common use case of quickly pasting sequential items 😃
Describe the solution you'd like
Hi @hluk, did you have the chance to check this in 'Discussions'? #1893
I'm opening the feature request here, just in case you missed that.
Thanks a lot 🙏!
The text was updated successfully, but these errors were encountered: