From 709db8f6de3a20058319a7c4daf74f0bba3b4ad4 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Thu, 25 May 2023 13:29:34 -0400 Subject: [PATCH] Re-use _copy_subject instead of _copy_line[_index] Former-commit-id: 541227f28a7a2bbe7c5e7fe98e3223e3fb3ba5ae Former-commit-id: 064b30c58d6905a68fa6684bb3ab17fd543f99cf --- lib/sshyp.py | 12 ++++++------ port-jobs/CLIPBOARD.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index 74b9193..5ed1007 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -653,28 +653,28 @@ def copy_data(): # PORT START CLIPBOARD # WSL clipboard detection if 'WSL_DISTRO_NAME' in environ: - run(('powershell.exe', '-c', "Set-Clipboard '" + _copy_line[_index].replace("'", "''") + "'")) + run(('powershell.exe', '-c', "Set-Clipboard '" + _copy_subject.replace("'", "''") + "'")) Popen("sleep 30; powershell.exe -c Set-Clipboard ''", shell=True, stdout=DEVNULL, stderr=DEVNULL) # Wayland clipboard detection elif 'WAYLAND_DISPLAY' in environ: - run(('wl-copy', _copy_line[_index])) + run(('wl-copy', _copy_subject)) Popen('sleep 30; wl-copy -c', shell=True) # Haiku clipboard detection elif uname()[0] == 'Haiku': - run(('clipboard', '-c', _copy_line[_index])) + run(('clipboard', '-c', _copy_subject)) Popen('sleep 30; clipboard -r', shell=True) # MacOS clipboard detection elif uname()[0] == 'Darwin': - run(('pbcopy'), stdin=Popen(('printf', _copy_line[_index].replace('\\', '\\\\').replace('%', '%%')), + run(('pbcopy'), stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\').replace('%', '%%')), stdout=PIPE).stdout) Popen("sleep 30; printf '' | pbcopy", shell=True) # Termux (Android) clipboard detection elif isdir("/data/data/com.termux"): - run(('termux-clipboard-set', _copy_line[_index])) + run(('termux-clipboard-set', _copy_subject)) Popen("sleep 30; termux-clipboard-set ''", shell=True) # X11 clipboard detection elif 'DISPLAY' in environ: - run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_line[_index].replace('\\', '\\\\') + run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\') .replace('%', '%%')), stdout=PIPE).stdout) Popen("sleep 30; printf '' | xclip -sel c", shell=True) else: diff --git a/port-jobs/CLIPBOARD.py b/port-jobs/CLIPBOARD.py index afef53e..ba52a54 100755 --- a/port-jobs/CLIPBOARD.py +++ b/port-jobs/CLIPBOARD.py @@ -8,25 +8,25 @@ arguments = argv[1:] # define replacement text depending on arguments if len(arguments) > 0: if arguments[0] == 'WSL': - replacement = """run(['powershell.exe', '-c', "Set-Clipboard '" + _copy_line[_index].rstrip()\ + replacement = """run(['powershell.exe', '-c', "Set-Clipboard '" + _copy_subject.rstrip()\ .replace("'", "''") + "'"]) Popen("sleep 30; powershell.exe -c Set-Clipboard ''", shell=True, stdout=DEVNULL, stderr=DEVNULL)""" elif arguments[0] == 'MAC': - replacement = """run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip()\ + replacement = """run(['pbcopy'], stdin=Popen(['printf', _copy_subject.rstrip()\ .replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')],stdout=PIPE).stdout) Popen("sleep 30; printf '' | pbcopy", shell=True)""" elif arguments[0] == 'HAIKU': - replacement = """run(['clipboard', '-c', _copy_line[_index].rstrip()]) + replacement = """run(['clipboard', '-c', _copy_subject.rstrip()]) Popen('sleep 30; clipboard -r', shell=True)""" elif arguments[0] == 'TERMUX': - replacement = """run(['termux-clipboard-set', _copy_line[_index].rstrip()]) + replacement = """run(['termux-clipboard-set', _copy_subject.rstrip()]) Popen("sleep 30; termux-clipboard-set ''", shell=True)""" elif arguments[0] == 'LINUX': replacement = """if 'WAYLAND_DISPLAY' in environ: - run(['wl-copy', _copy_line[_index].rstrip()]) + run(['wl-copy', _copy_subject.rstrip()]) Popen('sleep 30; wl-copy -c', shell=True) else: - run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_line[_index].rstrip()\ + run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_subject.rstrip()\ .replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')], stdout=PIPE).stdout) Popen("sleep 30; printf '' | xclip -sel c", shell=True)""" else: