Sunday, December 17, 2023

How I like to setup Copyq

settings

theres a lot of things you need to change to make this clipboard manager decent. a majorly annoying thing is when an item is selected in the list IT DOESNT ADD IT TO YOUR CLIPBOARD. the terminal you have to say copyq next, copyq previous (prev doesnt work!) grossly verbose.

enable vi motions (obviously)


enable autostart


disable closed when unfocused (default on is annoying)


preferences: appearances: enable darktheme


in history: set editor to gvim -f %1


max number of items in history i set to 10


layout: disable hide toolbar labels (default is off)


just use rofi

its kind of annoying in 3 ways.

  • you need to type out and remember long terminal commands
  • gui keeps dissapearing
  • even though you select it it doesnt copy

setting up rofi to deal with it instead is wayyyy better.


I have it set to pop up with ctrl period


            
#!/usr/bin/env python3

# https://github.com/albertlauncher/python/blob/master/CopyQ.py

import json
import subprocess as sp

copyq_script_getAll = r"""
var result=[];
for ( var i = 0; i < size(); ++i ) {
    var obj = {};
    obj.row = i;
    obj.mimetypes = str(read("?", i)).split("\n");
    obj.mimetypes.pop();
    obj.text = str(read(i));
    result.push(obj);
}
JSON.stringify(result);
"""


if __name__ == '__main__':
    p = sp.run('copyq -'.split(), input=copyq_script_getAll,
               encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE)
    json_arr = json.loads(p.stdout)

    items = []
    for json_obj in json_arr:
        text = json_obj['text']
        text = " ".join(filter(None, text.replace("\n", " ").split(" ")))
        items.append(text)

    title = 'rofi-copyq'
    rofi = f'rofi -dmenu -i -p {title} -format i'.split()
    rofi_input = '\n'.join(x for x in items)

    p = sp.run(rofi, input=rofi_input, encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE)
    if p.returncode == 0:
        num = p.stdout.strip()
        sp.run(f'copyq select({num});'.split(),
               encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE)
            
        

I put that text in a text file called roficlipq.py


startmenu: settings: keyboard: application shortcuts: python3 pathto roficopyq.py


qr code generation

this is a pretty cool feature


you enable by going to


preferences: shortcuts: application: create qr code from url (requires qrencode)

sudo apt install qrencode

i find this very handy

No comments:

Post a Comment