diff --git a/lib/sshyp.py b/lib/sshyp.py index 594eb83..c230ac7 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -378,6 +378,15 @@ this program comes with absolutely no warranty; type 'sshyp license' for details # PORT END HELP-SERVER +# shortcut to quickly read an entry +def read_shortcut(): + target_type_check(entry_name, True, True) + _shm_folder, _shm_entry = shm_gen() + determine_decrypt(directory + entry_name, _shm_folder, _shm_entry) + entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}") + rmtree(f"{tmp_dir}{_shm_folder}") + + # calls sshync to sync changes to the user's server def sync(): print('\nsyncing entries with the server device...\n') @@ -539,7 +548,7 @@ def rename(): from shutil import copy # check if the renaming target is an entry (file) or a folder - _file = target_type_check(entry_name) + _file = target_type_check(entry_name) # collect the new name for the target from user input _new_name = str(input('new name: ')).strip('/') @@ -665,8 +674,8 @@ def copy_data(): Popen('sleep 30; clipboard -r', shell=True) # MacOS clipboard detection elif uname()[0] == 'Darwin': - run(('pbcopy'), stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\').replace('%', '%%')), - stdout=PIPE).stdout) + 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"): @@ -679,7 +688,7 @@ def copy_data(): Popen("sleep 30; printf '' | xclip -sel c", shell=True) else: print('\n\u001b[38;5;9merror: clipboard tool could not be determined\n\nnote that the clipboard does not ' - 'function in a raw tty\u001b[0m\n') + 'function in a raw tty\u001b[0m\n') # PORT END CLIPBOARD rmtree(f"{tmp_dir}{_shm_folder}") @@ -816,13 +825,8 @@ if __name__ == "__main__": elif arg_count == 1: if arg_start == 1: - # read shortcut success_flag = True - target_type_check(entry_name, True, True) - _shm_folder, _shm_entry = shm_gen() - determine_decrypt(directory + entry_name, _shm_folder, _shm_entry) - entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}") - rmtree(f"{tmp_dir}{_shm_folder}") + read_shortcut() elif arguments[0] == 'tweak': success_flag = True from stweak import menu_repeat diff --git a/lib/stweak.py b/lib/stweak.py index 692d0de..ce1f32f 100644 --- a/lib/stweak.py +++ b/lib/stweak.py @@ -352,9 +352,9 @@ def initial_setup(): # PORT START CLIPTOOL # check for clipboard tool and display warning if missing - if uname()[0] in ('Linux', 'FreeBSD') and not 'WSL_DISTRO_NAME' in environ \ - and not exists("/data/data/com.termux"): - _display_server = None + if uname()[0] in ('Linux', 'FreeBSD') and 'WSL_DISTRO_NAME' not in environ \ + and not exists("/data/data/com.termux"): + _display_server, _clipboard_tool, _clipboard_package = None, None, None if 'WAYLAND_DISPLAY' in environ: _display_server, _clipboard_tool, _clipboard_package = 'Wayland', 'wl-copy', 'wl-clipboard' elif 'DISPLAY' in environ: diff --git a/port-jobs/CLIPBOARD.py b/port-jobs/CLIPBOARD.py index ba52a54..489ebb8 100755 --- a/port-jobs/CLIPBOARD.py +++ b/port-jobs/CLIPBOARD.py @@ -8,26 +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_subject.rstrip()\ - .replace("'", "''") + "'"]) + replacement = """run(('powershell.exe', '-c', "Set-Clipboard '" + _copy_subject.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_subject.rstrip()\ - .replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')],stdout=PIPE).stdout) + replacement = """run('pbcopy', stdin=Popen(('printf', _copy_subject.replace('\\\\\\', '\\\\\\\\\\\\\\') + .replace('%', '%%')), stdout=PIPE).stdout) Popen("sleep 30; printf '' | pbcopy", shell=True)""" elif arguments[0] == 'HAIKU': - replacement = """run(['clipboard', '-c', _copy_subject.rstrip()]) + replacement = """run(('clipboard', '-c', _copy_subject)) Popen('sleep 30; clipboard -r', shell=True)""" elif arguments[0] == 'TERMUX': - replacement = """run(['termux-clipboard-set', _copy_subject.rstrip()]) + replacement = """run(('termux-clipboard-set', _copy_subject)) Popen("sleep 30; termux-clipboard-set ''", shell=True)""" elif arguments[0] == 'LINUX': replacement = """if 'WAYLAND_DISPLAY' in environ: - run(['wl-copy', _copy_subject.rstrip()]) + run(('wl-copy', _copy_subject)) Popen('sleep 30; wl-copy -c', shell=True) else: - run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_subject.rstrip()\ - .replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')], stdout=PIPE).stdout) + run(('xclip', '-sel', 'c'), stdin=Popen(('printf', _copy_subject + .replace('\\\\\\', '\\\\\\\\\\\\\\').replace('%', '%%')), stdout=PIPE).stdout) Popen("sleep 30; printf '' | xclip -sel c", shell=True)""" else: s_exit() diff --git a/port-jobs/CLIPTOOL.py b/port-jobs/CLIPTOOL.py index 303156d..fd9cf57 100755 --- a/port-jobs/CLIPTOOL.py +++ b/port-jobs/CLIPTOOL.py @@ -13,7 +13,7 @@ string2 = '# PORT END CLIPTOOL' if len(arguments) > 0: regex = re.compile(f"{string1}.*?{string2}", re.DOTALL) replacement = """# check for clipboard tool and display warning if missing - _display_server = None + _display_server, _clipboard_tool, _clipboard_package = None, None, None if 'WAYLAND_DISPLAY' in environ: _display_server, _clipboard_tool, _clipboard_package = 'Wayland', 'wl-copy', 'wl-clipboard' elif 'DISPLAY' in environ: