Re-use _copy_subject instead of _copy_line[_index]

Former-commit-id: 541227f28a7a2bbe7c5e7fe98e3223e3fb3ba5ae
Former-commit-id: 064b30c58d6905a68fa6684bb3ab17fd543f99cf
This commit is contained in:
2023-05-25 13:29:34 -04:00
parent 273b3c97a5
commit 709db8f6de
2 changed files with 12 additions and 12 deletions
+6 -6
View File
@@ -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:
+6 -6
View File
@@ -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: