Skip to content

Commit 6cf577d

Browse files
committed
Prettied code <3:
- Made program more user-friendly - Small bug fixes - Made test.bat more efficient
1 parent f97a90c commit 6cf577d

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

main.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,28 +142,30 @@ async def main():
142142
winreg.SetValueEx(key, "SRR", 0, winreg.REG_SZ, str(PATH_TO_PROGRAM / "SRR.exe"))
143143
winreg.CloseKey(key)
144144

145-
if not Path.exists(PATH_TO_PROGRAM / "config.json"):
146-
with open(PATH_TO_PROGRAM / "config.json", "w") as config:
147-
params = cur_monitor_specs()
148-
json.dump(params, config, indent=4)
149-
150145
if PATH_BASE_DIR != PATH_TO_PROGRAM:
151146
if not is_app_running("SRR.exe"):
152147
os.startfile(PATH_TO_PROGRAM / "SRR.exe")
153148
else:
154-
ctypes.windll.user32.MessageBoxW(None, "Another instance of SRR is already running.",
155-
"Warning", 0)
149+
ctypes.windll.user32.MessageBoxW(
150+
None, "Another instance of SRR is already running.", "Warning", 0
151+
)
156152
os._exit(-1)
157153

154+
if not Path.exists(PATH_TO_PROGRAM / "config.json"):
155+
with open(PATH_TO_PROGRAM / "config.json", "w") as config:
156+
params = cur_monitor_specs()
157+
json.dump(params, config, indent=4)
158+
158159
powersave_state, performance_state = load_config()
159160

160161
try:
161162
with keyboard.Listener(on_press=on_press, on_release=on_release):
162163
await switch_rate(cur_power_state(), performance_state, powersave_state)
163164
await srr_loop(TIME_STEP, performance_state, powersave_state)
164165
except Exception as e:
165-
ctypes.windll.user32.MessageBoxW(None, f"The SRR program terminated with the following error:\n{repr(e)}",
166-
"Error", 0)
166+
ctypes.windll.user32.MessageBoxW(
167+
None, f"The SRR program terminated with the following error:\n{repr(e)}", "Error", 0
168+
)
167169
write_logs(e)
168170

169171

0 commit comments

Comments
 (0)