Skip to content

Commit 8ec66d8

Browse files
committed
Possible fix for language problem, though cannot test.
1 parent 3d53c04 commit 8ec66d8

File tree

3 files changed

+49
-33
lines changed

3 files changed

+49
-33
lines changed

G14Control.pyw

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import resources
1313
from G14RunCommands import RunCommands
1414
from G14Utils import (
1515
create_icon,
16+
get_g14plan,
1617
is_admin,
1718
get_app_path,
1819
rog_keyset,
@@ -222,21 +223,21 @@ def quit_app():
222223

223224
data.run_power_thread = False
224225
data.run_gaming_thread = False
225-
if data.power_thread is not None and data.power_thread.is_alive():
226-
data.power_thread.kill()
227-
while data.power_thread.isAlive():
228-
if data.config["debug"]:
229-
print("Waiting for power thread to die...")
230-
time.sleep(0.25)
231-
print("Power thread was alive, and now is dead.")
232-
233-
if data.gaming_thread is not None and data.gaming_thread.is_alive():
234-
data.gaming_thread.kill()
235-
while data.gaming_thread.isAlive():
236-
if data.config["debug"]:
237-
print("Waiting for gaming thread to die...")
238-
time.sleep(0.25)
239-
print("Gaming thread was alive, and now is dead.")
226+
# if data.power_thread is not None and data.power_thread.is_alive():
227+
# data.power_thread.kill()
228+
# while data.power_thread.isAlive():
229+
# if data.config["debug"]:
230+
# print("Waiting for power thread to die...")
231+
# time.sleep(0.25)
232+
# print("Power thread was alive, and now is dead.")
233+
234+
# if data.gaming_thread is not None and data.gaming_thread.is_alive():
235+
# data.gaming_thread.kill()
236+
# while data.gaming_thread.isAlive():
237+
# if data.config["debug"]:
238+
# print("Waiting for gaming thread to die...")
239+
# time.sleep(0.25)
240+
# print("Gaming thread was alive, and now is dead.")
240241
if device is not None:
241242
device.close()
242243
try:
@@ -253,13 +254,33 @@ class Windows_Plan_Check(threading.Thread):
253254
def run(self):
254255
global data
255256
while True:
257+
requires_reload = False
258+
259+
# Check for windows plan changes
256260
plan_tuple = re.findall(
257261
r"([0-9a-f\-]{36}) *\((.*)\)",
258262
os.popen("powercfg /GETACTIVESCHEME").read(),
259263
)
260264
if data.current_windows_plan != plan_tuple[0][1]:
265+
print("windows plan")
261266
data.update_win_plan(plan_tuple[0][1])
262267
data.current_windows_plan = plan_tuple[0][1]
268+
requires_reload = True
269+
270+
# Check for boost changes
271+
current = get_g14plan(data.current_plan, data.config)
272+
boost = data.main_cmds.get_boost()[-1]
273+
if int(boost) is not current["boost"]:
274+
print(boost, current["boost"], "Boost")
275+
requires_reload = True
276+
277+
# Check for gpu changes
278+
if current["dgpu_enabled"] is not data.main_cmds.get_dgpu():
279+
print(current["dgpu_enabled"], data.main_cmds.get_dgpu(), "DGPU")
280+
requires_reload = True
281+
282+
# If reload required, update menu.
283+
if requires_reload:
263284
global icon_app
264285
icon_app.update_menu()
265286
time.sleep(5)

G14RunCommands.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ def parse_boolean(self, parse_string):
4040

4141
def get_boost(self):
4242
# I know, it's ugly, but no other way to do that from py.
43-
current_pwr = os.popen("powercfg /GETACTIVESCHEME")
44-
pwr_guid = (
45-
current_pwr.readlines()[0].rsplit(": ")[1].rsplit(" (")[0].lstrip("\n")
46-
) # Parse the GUID
43+
pwr_guid = list(get_active_windows_plan().values())[0] # Parse the GUID
4744
SUB_PROCESSOR = " 54533251-82be-4824-96c1-47b60b740d00"
4845
PERFBOOSTMODE = " be337238-0d82-4146-a960-4f3749d470c7"
4946
# Let's get the boost option in the currently active power scheme
@@ -58,14 +55,11 @@ def get_boost(self):
5855

5956
def do_boost(self, state):
6057
# Just to be safe, let's get the current power scheme
61-
CURRENT_SCHEME = os.popen("powercfg /GETACTIVESCHEME")
6258
SUB_PROCESSOR = "54533251-82be-4824-96c1-47b60b740d00"
6359
PERFBOOSTMODE = "be337238-0d82-4146-a960-4f3749d470c7"
6460
set_ac = "powercfg /setacvalueindex"
6561
set_dc = "powercfg /setdcvalueindex"
66-
pwr_guid = (
67-
CURRENT_SCHEME.readlines()[0].rsplit(": ")[1].rsplit(" (")[0].lstrip("\n")
68-
) # Parse the GUID
62+
pwr_guid = list(get_active_windows_plan().values())[0]
6963
if state is False:
7064
state = 0
7165
SET_AC_VAL = "{0} {1} {2} {3} {4}".format(
@@ -128,16 +122,11 @@ def set_boost(self, state, notification=True):
128122

129123
def get_dgpu(self):
130124
# Get active windows power scheme
131-
current_pwr = os.popen("powercfg /GETACTIVESCHEME")
132-
CURRENT_GUID = re.findall(r"[0-9a-fA-F\-]{36}", current_pwr.read())[
133-
0
134-
] # Parse the GUID
125+
pwr_guid = list(get_active_windows_plan().values())[0] # Parse the GUID
135126
SW_DYNAMC_GRAPHICS = "e276e160-7cb0-43c6-b20b-73f5dce39954"
136127
GLOBAL_SETTINGS = "a1662ab2-9d34-4e53-ba8b-2639b9e20857"
137128
pwr_settings = os.popen(
138-
" ".join(
139-
["powercfg", "/q", CURRENT_GUID, SW_DYNAMC_GRAPHICS, GLOBAL_SETTINGS]
140-
)
129+
" ".join(["powercfg", "/q", pwr_guid, SW_DYNAMC_GRAPHICS, GLOBAL_SETTINGS])
141130
) # Let's get the dGPU status in the current power scheme
142131
output = pwr_settings.readlines() # We save the output to parse it afterwards
143132
# Convert to boolean for "On/Off"
@@ -150,8 +139,7 @@ def get_dgpu(self):
150139
def set_dgpu(self, state, notification=True):
151140
G14dir = self.G14dir
152141
# Just to be safe, let's get the current power scheme
153-
current_pwr = os.popen("powercfg /GETACTIVESCHEME")
154-
CURRENT_GUID = re.findall(r"[0-9a-fA-F\-]{36}", current_pwr.read())[0]
142+
pwr_guid = list(get_active_windows_plan().values())[0]
155143
SW_DYNAMC_GRAPHICS = "e276e160-7cb0-43c6-b20b-73f5dce39954"
156144
GLOBAL_SETTINGS = "a1662ab2-9d34-4e53-ba8b-2639b9e20857"
157145
AC = "/setacvalueindex"
@@ -163,7 +151,7 @@ def _set_dgpu(SETTING, AC_DC):
163151
[
164152
"powercfg",
165153
AC_DC,
166-
CURRENT_GUID,
154+
pwr_guid,
167155
SW_DYNAMC_GRAPHICS,
168156
GLOBAL_SETTINGS,
169157
str(SETTING),

G14Utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ def get_windows_theme():
182182
return value # 1 for light theme, 0 for dark theme
183183

184184

185+
def get_g14plan(current, config):
186+
plans = config["plans"]
187+
for p in plans:
188+
if p["name"] == current:
189+
return p
190+
191+
185192
def create_icon(config):
186193
if (
187194
get_windows_theme() == 0

0 commit comments

Comments
 (0)