Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
gorouflex authored Jan 30, 2024
1 parent 92e138c commit c845e0d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 22 deletions.
Binary file added RielUXTU/DirectHW.kext.zip
Binary file not shown.
93 changes: 71 additions & 22 deletions RielUXTU/RielUXTU.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import sys
import time
import os
import urllib.request
from configparser import ConfigParser

PRESETS = {
"Eco": (
Expand Down Expand Up @@ -62,36 +64,83 @@
)
}

def create_config() -> None:
cfg: ConfigParser = ConfigParser()
cfg.add_section('User')
print("------ First time setup ------")
print("Preset power plan")
for i, mode in enumerate(PRESETS, start=1):
print(f"{i}. {mode}")

choice = input("Choose your preset power plan by pressing number: ")
try:
preset_number = int(choice)
preset_name = list(PRESETS.keys())[preset_number - 1]
cfg.set('User', 'Mode', preset_name)
with open('config.ini', 'w') as config_file:
cfg.write(config_file)
except ValueError:
print("Invalid input. Please enter a number.")

def read_config() -> str:
cfg: ConfigParser = ConfigParser()
cfg.read('config.ini')
return cfg.get('User', 'Mode', fallback='')

def check_config_integrity(conf: ConfigParser) -> None:
config_path = 'config.ini'

if not os.path.isfile(config_path) or os.stat(config_path).st_size == 0:
create_config()
return

conf.read(config_path)

if not conf.has_section('User'):
create_config()

def get_latest_version():
latest_version_url = "https://github.com/gorouflex/rieluxtu4mac/releases/latest"
latest_version = urllib.request.urlopen(latest_version_url).geturl()
return latest_version.split("/")[-1]

def check_for_updates():
local_version = "0.0.4"
latest_version = get_latest_version()

if local_version < latest_version:
print("A new update is available! Please visit the following link for details:")
print("https://github.com/gorouflex/RielUXTU4Mac/releases/latest")
sys.exit()
elif local_version > latest_version:
print("Welcome to RielUXTU4Mac Beta Program.")
print("This build may not be as stable as expected. Only for testing purposes!")
result = input("Do you want to continue? (y/n): ").lower()
if result != "y":
sys.exit()

def clear():
_ = os.system('cls') if os.name == 'nt' else os.system('clear')

def run_command(args):
command = ["sudo", "./ryzenadj"] + args.split()
while True:
subprocess.run(command)
time.sleep(3)
print("Script will reapplied every 3 seconds since RyzenAdj can easily reset just like UXTU")
clear()
print("Script will be reapplied every 3 seconds since RyzenAdj can easily reset just like UXTU")


if len(sys.argv) > 1:
user_input = sys.argv[1]
try:
preset_number = int(user_input)
preset_name = list(PRESETS.keys())[preset_number - 1]
run_command(PRESETS[preset_name])
except ValueError:
run_command(user_input)
else:
print("Current Preset:")
for i, preset in enumerate(PRESETS, start=1):
print(f"{i}. {preset}")
user_input = input("Choose a preset by enter number or enter custom arguments: ")
print("Script will reapplied every 3 seconds since RyzenAdj can easily reset just like UXTU")
check_for_updates()

try:
preset_number = int(user_input)
preset_name = list(PRESETS.keys())[preset_number - 1]
run_command(PRESETS[preset_name])
except ValueError:
run_command(user_input)
config = ConfigParser()
check_config_integrity(config)
config.read('config.ini')

user_mode = read_config()

if user_mode:
print(f"Using mode: {user_mode}")
run_command(PRESETS[user_mode])
else:
print("Config file is missing or invalid. Please run the script again.")

0 comments on commit c845e0d

Please sign in to comment.