From 97bce0cec741cca76e300ef9961b5586c841e8b4 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Thu, 25 May 2023 13:59:22 -0400 Subject: [PATCH] Repeat the tweak menu after each choice path is completed Former-commit-id: 4b49d43f13fbb006c5315e9be677bcc33dd2ac20 Former-commit-id: ac447b63ec5cb5e85dc9133466a434be0786c30d --- lib/sshyp.py | 4 ++-- lib/stweak.py | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index 5ed1007..594eb83 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -825,8 +825,8 @@ if __name__ == "__main__": rmtree(f"{tmp_dir}{_shm_folder}") elif arguments[0] == 'tweak': success_flag = True - from stweak import global_menu - global_menu(False) + from stweak import menu_repeat + menu_repeat(False) # PORT START ARGS-SERVER # server arguments diff --git a/lib/stweak.py b/lib/stweak.py index b5c0a6d..5f2bd3c 100644 --- a/lib/stweak.py +++ b/lib/stweak.py @@ -231,6 +231,16 @@ def quick_unlock_config(_default): return _enabled +# continually shows the tweak menu after each change until the user manually exits +def menu_repeat(_post_setup): + try: + while True: + if global_menu(_post_setup): + break + except KeyboardInterrup: + s_exit(0) + + # runs secondary configuration menu def global_menu(_post_setup): # curses initialization @@ -238,7 +248,7 @@ def global_menu(_post_setup): cbreak() stdscr.keypad(True) - _options, _choice, _term_message = [], 4, False + _options, _choice, _term_message, _return_val = [], 4, False, False try: if not _post_setup: _options.extend(['change device/synchronization types', 'change gpg key', 're-configure ssh(ync)', @@ -277,11 +287,12 @@ def global_menu(_post_setup): "\nyou must first log in to the sshyp server and run:\n\nsshyp whitelist setup (if not" " already done)\nsshyp whitelist add " f"'{listdir(f'{home}/.config/sshyp/devices')[0].rstrip()}'\n") - else: - pass + elif _choice == 8: + _return_val = True curses_terminate(_term_message) except KeyboardInterrupt: curses_terminate(False) + return _return_val # runs initial configuration wizard @@ -356,7 +367,7 @@ def initial_setup(): f'"{_clipboard_package}" is installed\u001b[0m') # PORT END CLIPTOOL - global_menu(True) + menu_repeat(True) except KeyboardInterrupt: # cleanly exit curses