mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-31 06:16:29 -04:00
Re-use _copy_subject instead of _copy_line[_index]
Former-commit-id: 541227f28a7a2bbe7c5e7fe98e3223e3fb3ba5ae Former-commit-id: 064b30c58d6905a68fa6684bb3ab17fd543f99cf
This commit is contained in:
+6
-6
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user