From 1658eefe4205fabc5f5067f1d39d8f9dbb5da218 Mon Sep 17 00:00:00 2001 From: GorouFlex <98001973+gorouflex@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:56:29 +0700 Subject: [PATCH] bump --- Linux/UXTU4Unix.py | 80 +++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 51 deletions(-) diff --git a/Linux/UXTU4Unix.py b/Linux/UXTU4Unix.py index 116bbd3..733750f 100644 --- a/Linux/UXTU4Unix.py +++ b/Linux/UXTU4Unix.py @@ -11,14 +11,12 @@ import select from configparser import ConfigParser -# Constants -LOCAL_VERSION = "0.3.03" +LOCAL_VERSION = "0.3.1" LATEST_VERSION_URL = "https://github.com/HorizonUnix/UXTU4Unix/releases/latest" GITHUB_API_URL = "https://api.github.com/repos/HorizonUnix/UXTU4Unix/releases/latest" current_dir = os.path.dirname(os.path.realpath(__file__)) CONFIG_PATH = os.path.join(current_dir, 'Assets', 'config.ini') -# Setup Logging log_dir = os.path.join(current_dir, 'Logs') os.makedirs(log_dir, exist_ok=True) logging.basicConfig( @@ -31,7 +29,6 @@ ) logging.getLogger().addHandler(logging.StreamHandler()) -# Load Configurations cfg = ConfigParser() cfg.read(CONFIG_PATH) @@ -279,12 +276,11 @@ def settings(): options = { "1": preset_cfg, "2": sleep_cfg, - "3": dynamic_cfg, - "4": reapply_cfg, - "5": applystart_cfg, - "6": cfu_cfg, - "7": pass_cfg, - "8": debug_cfg, + "3": reapply_cfg, + "4": applystart_cfg, + "5": cfu_cfg, + "6": pass_cfg, + "7": debug_cfg, "r": reset, "b": "break" } @@ -292,13 +288,13 @@ def settings(): clear() logging.info("--------------- Settings ---------------") logging.info("1. Preset\n2. Sleep time") - logging.info("3. Dynamic mode\n4. Auto reapply") - logging.info("5. Apply on start") - logging.info("6. Software update") - logging.info("7. Sudo password") - logging.info("8. Debug\n") + logging.info("3. Auto reapply") + logging.info("4. Apply on start") + logging.info("5. Software update") + logging.info("6. Sudo password") + logging.info("7. Debug\n") logging.info("R. Reset all saved settings") - logging.info("B. Back") + logging.info("B. Back\n") settings_choice = input("Option: ").lower().strip() action = options.get(settings_choice, None) if action is None: @@ -316,7 +312,7 @@ def applystart_cfg(): logging.info("(Apply preset when start)") start_enabled = cfg.get('Settings', 'ApplyOnStart', fallback='1') == '1' logging.info("Status: Enabled" if start_enabled else "Status: Disabled") - logging.info("\n1. Enable Apply on start\n2. Disable Apply on start\n\nB. Back") + logging.info("\n1. Enable Apply on start\n2. Disable Apply on start\n\nB. Back\n") choice = input("Option: ").strip() if choice == "1": cfg.set('Settings', 'ApplyOnStart', '1') @@ -337,7 +333,7 @@ def debug_cfg(): logging.info("(Display some process information)") debug_enabled = cfg.get('Settings', 'Debug', fallback='1') == '1' logging.info("Status: Enabled" if debug_enabled else "Status: Disabled") - logging.info("\n1. Enable Debug\n2. Disable Debug\n\nB. Back") + logging.info("\n1. Enable Debug\n2. Disable Debug\n\nB. Back\n") choice = input("Option: ").strip() if choice == "1": cfg.set('Settings', 'Debug', '1') @@ -358,7 +354,7 @@ def reapply_cfg(): logging.info("(Automatic reapply preset)") reapply_enabled = cfg.get('Settings', 'ReApply', fallback='0') == '1' logging.info("Status: Enabled" if reapply_enabled else "Status: Disabled") - logging.info("\n1. Enable Auto reapply\n2. Disable Auto reapply\n\nB. Back") + logging.info("\n1. Enable Auto reapply\n2. Disable Auto reapply\n\nB. Back\n") choice = input("Option: ").strip() if choice == "1": cfg.set('Settings', 'ReApply', '1') @@ -372,34 +368,13 @@ def reapply_cfg(): with open(CONFIG_PATH, 'w') as config_file: cfg.write(config_file) -def dynamic_cfg(): - while True: - clear() - dm_enabled = cfg.get('Settings', 'DynamicMode', fallback='0') == '1' - logging.info("--------------- Dynamic mode ---------------") - logging.info("(Automatic switch preset based on your battery usage)") - logging.info("Status: Enabled" if dm_enabled else "Status: Disabled") - logging.info("\n1. Enable Dynamic Mode\n2. Disable Dynamic Mode\n\nB. Back") - choice = input("Option: ").strip() - if choice == "1": - cfg.set('Settings', 'DynamicMode', '1') - elif choice == "2": - cfg.set('Settings', 'DynamicMode', '0') - elif choice.lower() == "b": - break - else: - logging.info("Invalid option.") - input("Press Enter to continue...") - with open(CONFIG_PATH, 'w') as config_file: - cfg.write(config_file) - def sleep_cfg(): while True: clear() time = cfg.get('Settings', 'Time', fallback='30') logging.info("--------------- Sleep time ---------------") logging.info(f"Auto reapply every: {time} seconds") - logging.info("\n1. Change\n\nB. Back") + logging.info("\n1. Change\n\nB. Back\n") choice = input("Option: ").strip() if choice == "1": set_time = input("Enter your auto reapply time (Default is 30): ") @@ -418,7 +393,7 @@ def pass_cfg(): pswd = cfg.get('User', 'Password', fallback='') logging.info("--------------- Sudo password ---------------") logging.info(f"Current sudo (login) password: {pswd}") - logging.info("\n1. Change password\n\nB. Back") + logging.info("\n1. Change password\n\nB. Back\n") choice = input("Option: ").strip() if choice == "1": while True: @@ -445,7 +420,7 @@ def cfu_cfg(): cfu_enabled = cfg.get('Settings', 'SoftwareUpdate', fallback='1') == '1' logging.info("--------------- Software update ---------------") logging.info(f"Status: {'Enabled' if cfu_enabled else 'Disabled'}") - logging.info("\n1. Enable Software update\n2. Disable Software update\n\nB. Back") + logging.info("\n1. Enable Software update\n2. Disable Software update\n\nB. Back\n") choice = input("Option: ").strip() if choice == "1": cfg.set('Settings', 'SoftwareUpdate', '1') @@ -467,7 +442,7 @@ def preset_cfg(): for i, (preset_name, preset_value) in enumerate(PRESETS.items(), start=1): logging.info(f"{i}. {preset_name}") logging.info("\nD. Dynamic Mode\nC. Custom (Beta)\nB. Back") - logging.info("We recommend using the Dynamic Mode for normal tasks and better power management") + logging.info("We recommend using the Dynamic Mode for normal tasks and better power management\n") choice = input("Option: ").lower().strip() if choice == 'c': custom_args = input("Enter your custom arguments: ") @@ -544,7 +519,7 @@ def updater(): logging.info("--------------- UXTU4Unix Software Update ---------------") logging.info("A new update is available!") logging.info(f"Changelog for the latest version ({get_latest_ver()}):\n{changelog}") - logging.info("Do you want to update? (y/n): ") + logging.info("Do you want to update? (y/n): \n") choice = input("Option: ").lower().strip() if choice == "y": subprocess.run(["python3", os.path.join(current_dir, 'Assets', 'SU.py')]) @@ -601,19 +576,19 @@ def about(): while True: clear() logging.info("About UXTU4Unix") - logging.info("The New Future Vision Update (3Linux290724)") + logging.info("The New Vision Update (3Linux040824)") logging.info("----------------------------") logging.info("Maintainer: GorouFlex\nCLI: GorouFlex") logging.info("GUI: NotchApple1703\nCore: NotchApple1703") logging.info("Advisor: NotchApple1703") logging.info("dmidecode for macOS: Acidanthera") - logging.info("Command file for macOS: CorpNewt\nTester: nlqanh524") + logging.info("Command file for macOS: CorpNewt") logging.info("----------------------------") try: logging.info(f"F. Force update to the latest version ({get_latest_ver()})") except: pass - logging.info("\nB. Back") + logging.info("\nB. Back\n") choice = input("Option: ").lower().strip() action = options.get(choice, None) if action is None: @@ -628,7 +603,7 @@ def preset_menu(): PRESETS = get_presets() clear() logging.info("Apply power management settings:") - logging.info("1. Load saved settings from config file\n2. Load from available premade preset\n\nD. Dynamic Mode\nC. Custom\nB. Back") + logging.info("1. Load saved settings from config file\n2. Load from available premade preset\n\nD. Dynamic Mode\nC. Custom\nB. Back\n") preset_choice = input("Option: ").strip() if preset_choice == "1": user_mode = read_cfg() @@ -647,7 +622,7 @@ def preset_menu(): logging.info("Select a premade preset:") for i, mode in enumerate(PRESETS, start=1): logging.info(f"{i}. {mode}") - preset_number = input("Option: ").strip() + preset_number = input("\nOption: ").strip() try: preset_number = int(preset_number) if 1 <= preset_number <= len(PRESETS): @@ -672,8 +647,11 @@ def preset_menu(): cfg.set('Settings', 'DynamicMode', last_mode) cfg.set('Settings', 'ReApply', last_apply) elif preset_choice.lower() == "c": + last_mode = cfg.get('Settings', 'DynamicMode', fallback='0') + cfg.set('Settings', 'DynamicMode', '0') custom_args = input("Enter your custom arguments: ") apply_smu('Custom', custom_args, save_to_config=False) + cfg.set('Settings', 'DynamicMode', last_mode) elif preset_choice.lower() == "b": return else: @@ -786,7 +764,7 @@ def main(): logging.info("") logging.info("H. Hardware Information") logging.info("A. About UXTU4Unix") - logging.info("Q. Quit") + logging.info("Q. Quit\n") choice = input("Option: ").lower().strip() if action := options.get(choice): action()