Skip to content

Instantly share code, notes, and snippets.

@hluk
hluk / CopyQ - Move Items to Other Tab.ini
Last active August 29, 2015 14:02
CopyQ 2.3.0 user commands to move selected items to next or previous tab
[Commands]
1\Name=Move To Next Tab
1\Command="
copyq:
how = +1
source = selectedtab()
tabs = tab()
i = tabs.indexOf(source)
j = (i + tabs.length + how) % tabs.length
@hluk
hluk / CopyQ - Edit File.ini
Last active March 7, 2016 08:14
CopyQ - Edit File
[Command]
Name=Edit File
Match=^([a-zA-Z]:[\\\\/]|~|file://|%\\w+%|$\\w+|/)
Command="
copyq:
var editor = config('editor')
var fileName = str(input())
.replace(/^\\/([a-zA-Z])\\//, '$1:/')
.replace(/^file:\\/\\//, '')
@hluk
hluk / CopyQ - Store Copy Time.ini
Last active March 24, 2017 14:34
CopyQ - Store Copy Time
[Command]
Automatic=true
Command="
copyq:
var item = unpack(input())
item['application/x-copyq-time'] = dateString('yyyyMMddhhmmss')
write(0, \"application/x-copyq-item\", pack(item))"
Icon=\xf017
Input=application/x-copyq-item
Name=Store Copy Time
@hluk
hluk / CopyQ - Save Texts on Disk.ini
Last active March 24, 2017 14:34
CopyQ - Save Texts on Disk
[Command]
Name=Save Texts from Tab
Command="
copyq:
function encodeFileName(name)
{
return name.replace(/\\s/g, '_').replace(/\\W/g, '')
}
function addFileNamePart(fileName, item, mime)
@hluk
hluk / pdc_client.py
Last active September 26, 2017 08:25
class PDCClientWrapper(object):
def __init__(self, client, page_size):
self.client = client
self.page_size = page_size
def __call__(self, *args, **kwargs):
if 'page_size' not in kwargs:
kwargs['page_size'] = self.page_size
return self.client(*args, **kwargs)
@hluk
hluk / CopyQ - Frequent Items.ini
Last active March 11, 2018 23:48
CopyQ 2.3.0 user commands to add frequent items to special tab and to show frequent items
[Commands]
1\Name=Activate and Add to Frequent
1\Command="
copyq:
tab_name = \"Frequent\"
source = selectedtab()
tab(source)
items = selecteditems()
p = \"application/x-copyq-\"
@hluk
hluk / move_cursor_to_active_win.py
Created August 21, 2018 17:48
Move Mouse Cursor to Active Window
#!/usr/bin/env python3
import pyatspi
def on_object_focused(event):
if not event.source.getState().contains(pyatspi.STATE_FOCUSED):
return
print(event)
extents = event.source.get_extents(pyatspi.DESKTOP_COORDS)
@hluk
hluk / paste_separated.ini
Last active June 1, 2019 11:54
CopyQ Command: Paste multiple items separated by a blank line
[Command]
Command="
copyq:
hide()
var items = selectedItemsData()
var text = ''
for (var i in items) {
var itemText = str(items[i][mimeText]).trim()
text += itemText + '\\n\\n'
@hluk
hluk / add_blank_line.ini
Last active June 2, 2019 05:43
CopyQ Command: Add blank line when copied
[Command]
Automatic=true
Command="
copyq:
var text = str(data(mimeText))
if (!text)
abort()
text += '\\n\\n'
setData(mimeText, text)
@hluk
hluk / show_clipboard_owner.ini
Created August 3, 2019 09:05
CopyQ Command: Show clipboard owner in notification
[Command]
Command="
function showOwner() {
popup(
isClipboard() ? 'Clipboard Owner' : 'Selection Owner',
data(mimeWindowTitle)
)
}
var onClipboardChanged_ = onClipboardChanged