From 7cb245eddee780a264d4ec93104fcd9563c628ef Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 23 Oct 2023 20:37:41 -0400 Subject: [PATCH] Fix CLIPCLEAR port-job for generic Linux (Wayland/X11) Former-commit-id: 3690a41cbfce5eff13388fa7c9fe9f39d6e36865 Former-commit-id: a9a991dc141d1eb7d7973f8ecb08188dda27953b --- lib/clipclear.py | 26 +++++++++++++------------- port-jobs/CLIPBOARD.py | 30 +++++++++++++++--------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/clipclear.py b/lib/clipclear.py index 073c2bc..09cea2d 100755 --- a/lib/clipclear.py +++ b/lib/clipclear.py @@ -7,36 +7,36 @@ from time import sleep # set period of time to wait before attempting to clear clipboard sleep(30) # enable the storing of clipboard contents hash for later comparison -_hash_paste = sha512() +hash_paste = sha512() # PORT START CLIPCLEAR if argv[2] == 'wsl': - _hash_paste.update(run(('powershell.exe', '-c', 'Get-Clipboard'), stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run(('powershell.exe', '-c', 'Get-Clipboard'), stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(('powershell.exe', '-c', 'Set-Clipboard')) elif argv[2] == 'wayland': - _hash_paste.update(run('wl-paste', stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run('wl-paste', stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(('wl-copy', '-c')) elif argv[2] == 'haiku': - _hash_paste.update(run(('clipboard', '-p'), stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run(('clipboard', '-p'), stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(('clipboard', '-r')) elif argv[2] == 'mac': - _hash_paste.update(run(('pbpaste'), stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run('pbpaste', stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run('pbcopy', input=b'') elif argv[2] == 'termux': - _hash_paste.update(run(('termux-clipboard-get'), stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run('termux-clipboard-get', stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(("termux-clipboard-set", "''")) elif argv[2] == 'x11': - _hash_paste.update(run(('xclip', '-o', '-sel', 'c'), stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run(('xclip', '-o', '-sel', 'c'), stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(('xclip', '-i', '/dev/null', '-sel', 'c')) # PORT END CLIPCLEAR diff --git a/port-jobs/CLIPBOARD.py b/port-jobs/CLIPBOARD.py index 6e927af..d193d33 100755 --- a/port-jobs/CLIPBOARD.py +++ b/port-jobs/CLIPBOARD.py @@ -10,26 +10,26 @@ if len(arguments) > 0: if arguments[0] == 'WSL': clip_replacement = """run(('powershell.exe', '-c', "Set-Clipboard '" + _copy_subject.replace("'", "''") + "'")) Popen((realpath(__file__).rsplit('/', 1)[0] + "/clipclear.py", _hash.hexdigest(), 'wsl'), stdout=DEVNULL, stderr=DEVNULL)""" - clear_replacement = """_hash_paste.update(run(('powershell.exe', '-c', 'Get-Clipboard'), stdout=PIPE).stdout.strip()) -if argv[1] == _hash_paste.hexdigest(): + clear_replacement = """hash_paste.update(run(('powershell.exe', '-c', 'Get-Clipboard'), stdout=PIPE).stdout.strip()) +if argv[1] == hash_paste.hexdigest(): run(('powershell.exe', '-c', 'Set-Clipboard'))""" elif arguments[0] == 'MAC': clip_replacement = """run('pbcopy', stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout) Popen((realpath(__file__).rsplit('/', 1)[0] + "/clipclear.py", _hash.hexdigest(), 'mac'))""" - clear_replacement = """_hash_paste.update(run(('pbpaste'), stdout=PIPE).stdout.strip()) -if argv[1] == _hash_paste.hexdigest(): + clear_replacement = """hash_paste.update(run('pbpaste', stdout=PIPE).stdout.strip()) +if argv[1] == hash_paste.hexdigest(): run('pbcopy', input=b'')""" elif arguments[0] == 'HAIKU': clip_replacement = """run(('clipboard', '-c', _copy_subject)) Popen((realpath(__file__).rsplit('/', 1)[0] + "/clipclear.py", _hash.hexdigest(), 'haiku'))""" - clear_replacement = """_hash_paste.update(run(('clipboard', '-p'), stdout=PIPE).stdout.strip()) -if argv[1] == _hash_paste.hexdigest(): + clear_replacement = """hash_paste.update(run(('clipboard', '-p'), stdout=PIPE).stdout.strip()) +if argv[1] == hash_paste.hexdigest(): run(('clipboard', '-r'))""" elif arguments[0] == 'TERMUX': clip_replacement = """run(('termux-clipboard-set', _copy_subject)) Popen((realpath(__file__).rsplit('/', 1)[0] + "/clipclear.py", _hash.hexdigest(), 'termux'))""" - clear_replacement = """_hash_paste.update(run(('termux-clipboard-get'), stdout=PIPE).stdout.strip()) -if argv[1] == _hash_paste.hexdigest(): + clear_replacement = """hash_paste.update(run('termux-clipboard-get', stdout=PIPE).stdout.strip()) +if argv[1] == hash_paste.hexdigest(): run(("termux-clipboard-set", "''"))""" elif arguments[0] in ('LINUX', 'BSD'): clip_replacement = """if 'WAYLAND_DISPLAY' in environ: @@ -39,18 +39,18 @@ if argv[1] == _hash_paste.hexdigest(): run(('xclip', '-sel', 'c'), stdin=Popen(('printf', '%b', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\')), stdout=PIPE).stdout) Popen((realpath(__file__).rsplit('/', 1)[0] + "/clipclear.py", _hash.hexdigest(), 'x11'))""" clear_replacement = """if argv[2] == 'wayland': - _hash_paste.update(run('wl-paste', stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): + hash_paste.update(run('wl-paste', stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(('wl-copy', '-c')) -else - _hash_paste.update(run(('xclip', '-o', '-sel', 'c'), stdout=PIPE).stdout.strip()) - if argv[1] == _hash_paste.hexdigest(): +else: + hash_paste.update(run(('xclip', '-o', '-sel', 'c'), stdout=PIPE).stdout.strip()) + if argv[1] == hash_paste.hexdigest(): run(('xclip', '-i', '/dev/null', '-sel', 'c'))""" else: s_exit() -targets = (('CLIPBOARD', 'sshyp.py', '', '', clip_replacement), - ('CLIPCLEAR', 'clipclear.py', '\n', '', clear_replacement)) +targets = (('CLIPBOARD', 'sshyp.py', '', '', clip_replacement), + ('CLIPCLEAR', 'clipclear.py', '\n', '', clear_replacement)) for target in targets: # read text from target file