From 3f6d0749e3b23aea69f690446ea6b890a315f982 Mon Sep 17 00:00:00 2001 From: cronyakatsuki <64900606+cronyakatsuki@users.noreply.github.com> Date: Sat, 12 Nov 2022 17:14:33 +0100 Subject: [PATCH] Added ability to get current profile, fix stapm spelling mistake. --- main.py | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index c8321c6..f341e6b 100755 --- a/main.py +++ b/main.py @@ -28,6 +28,12 @@ lib.get_slow_limit.argtypes = [c_void_p] # Fast limit and value lib.get_fast_limit.restype = c_float lib.get_fast_limit.argtypes = [c_void_p] +# Slow time and value +lib.get_slow_time.restype = c_float +lib.get_slow_time.argtypes = [c_void_p] +# stapm time and value +lib.get_stapm_time.restype = c_float +lib.get_stapm_time.argtypes = [c_void_p] # Vrm Max Current and value lib.get_vrmmax_current.restype = c_float lib.get_vrmmax_current.argtypes = [c_void_p] @@ -95,11 +101,11 @@ def list_by_category(list, config): def set_from_config(config, profile): - adjust("stapm_limit", config.getint(profile, 'stamp-limit')) + adjust("stapm_limit", config.getint(profile, 'stapm-limit')) adjust("fast_limit", config.getint(profile, 'fast-limit')) adjust("slow_limit", config.getint(profile, 'slow-limit')) adjust("slow_time", config.getint(profile, 'slow-time')) - adjust("stapm_time", config.getint(profile, 'stamp-time')) + adjust("stapm_time", config.getint(profile, 'stapm-time')) adjust("tctl_temp", config.getint(profile, 'tctl-temp')) adjust("vrmmax_current", config.getint(profile, 'vrmmax-current')) @@ -109,6 +115,30 @@ def set_from_config(config, profile): enable("power_saving") +def get_current_profile(config): + profiles = config.sections() + lib.refresh_table(ry) + current = { + 'stapm-limit' : f'{round(lib.get_stapm_limit(ry) * 1000)}', + 'fast-limit' : f'{round(lib.get_fast_limit(ry) * 1000)}', + 'slow-limit' : f'{round(lib.get_slow_limit(ry) * 1000)}', + 'slow-time' : f'{round(lib.get_slow_time(ry))}', + 'stapm-time' : f'{round(lib.get_stapm_time(ry))}', + 'tctl-temp' : f'{round(lib.get_tctl_temp(ry))}', + 'vrmmax-current' : f'{round(lib.get_vrmmax_current(ry) * 1000)}', + } + + for profile in profiles: + options = dict(config.items(profile)) + options.pop('category') + options.pop('max-performance') + if current == options: + print(profile) + sys.exit(0) + + print("system-default") + sys.exit(0) + def main(): parser = argparse.ArgumentParser() parser.add_argument('-v', '--version', action='store_true', @@ -125,6 +155,8 @@ def main(): set.add_argument('profile', type=str, metavar='PROFILE', action='store', nargs='?', help="Profile name from the config") + subparser.add_parser('get', help="Get current profile") + config = configparser.ConfigParser() if os.path.isfile((CONFIG_FILE)): @@ -162,6 +194,8 @@ def main(): print('Profile must be provided') sys.exit(1) + if args.command == 'get': + get_current_profile(config) if __name__ == "__main__": main()