[Linux] Fix rofi_clipit

This commit is contained in:
Ivan Malison 2018-05-03 10:40:31 -07:00
parent 551072f24e
commit 1c5a54f3f6
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8
5 changed files with 4 additions and 24 deletions

View File

@ -4,7 +4,6 @@ import appdirs
import argparse import argparse
import os import os
import struct import struct
import string
clipit_history_file = os.path.join(appdirs.user_data_dir(), "clipit/history") clipit_history_file = os.path.join(appdirs.user_data_dir(), "clipit/history")
@ -17,7 +16,7 @@ def get_clipit_history(filename):
while (size > 0): while (size > 0):
item = f.read(size) item = f.read(size)
if item: if item:
yield item yield item.decode('utf-8')
_, _, _, size, _ = struct.unpack('5i', f.read(20)) _, _, _, size, _ = struct.unpack('5i', f.read(20))
@ -57,6 +56,6 @@ if __name__ == '__main__':
text = history[args.index] text = history[args.index]
else: else:
selected = history[args.begin_index:args.end_index] selected = history[args.begin_index:args.end_index]
text = args.separator.join([string.replace(s, args.separator, args.separator_replacement) text = args.separator.join([s.replace(args.separator, args.separator_replacement)
for s in selected]) for s in selected])
print(text, end='') print(text, end='')

View File

@ -1,9 +0,0 @@
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.split(search).join(replacement);
};
for (var i=0; i<size(); i++) {
var item = str(read(i));
print("(" + i + ")" + " " + item.replaceAll("\\n", "(newline)") + "\\n");
}

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
SOURCE_DIR="$(dirname ${BASH_SOURCE[0]})"
copyq eval "$(cat $SOURCE_DIR/copyq_all.js)"

View File

@ -1,8 +0,0 @@
#!/usr/bin/env bash
SELECTED_INDEX="$(copyq_all.sh | rofi -dmenu -format i)"
if [ "$SELECTED_INDEX" -eq "$SELECTED_INDEX" ] 2>/dev/null; then
copyq select "$SELECTED_INDEX"
copyq paste
fi

View File

@ -5,3 +5,5 @@ SELECTED_INDEX="$(clipit_history.py -r '(newline)' | rofi -dmenu -format i)"
if [ "$SELECTED_INDEX" -eq "$SELECTED_INDEX" ] 2>/dev/null; then if [ "$SELECTED_INDEX" -eq "$SELECTED_INDEX" ] 2>/dev/null; then
xdotool type "$(clipit_history.py -e 5 -i $SELECTED_INDEX)" xdotool type "$(clipit_history.py -e 5 -i $SELECTED_INDEX)"
fi fi
xdotool type