@@ -22,7 +22,6 @@ def __init__(self, config, G14dir, app_GUID, dpp_GUID, notify, windows_plans, ac
2222 def set_windows_and_active_plans (self , winplns , activeplns ):
2323 self .active_plan_map = activeplns
2424 self .windows_plans = winplns
25-
2625 # noinspection PyBroadException
2726
2827 # Small utility to convert windows HEX format to a boolean.
@@ -70,25 +69,16 @@ def do_boost(self, state):
7069 creationflags = subprocess .CREATE_NO_WINDOW )
7170 subprocess .Popen (SET_DC_VAL , shell = True ,
7271 creationflags = subprocess .CREATE_NO_WINDOW )
73- print (SET_AC_VAL )
74- print (SET_DC_VAL )
72+ self .finalize_powercfg_chg (pwr_guid )
73+ if self .config ['debug' ]:
74+ print (SET_AC_VAL )
75+ print (SET_DC_VAL )
7576
7677 def set_boost (self , state , notification = True ):
77- current_boost_mode = state
78- win_plans = self .windows_plans
79- active_plans = self .active_plan_map
80- windows_plan_map = self .windows_plan_map
8178 CURRENT_SCHEME = os .popen ("powercfg /GETACTIVESCHEME" )
8279 pwr_guid = CURRENT_SCHEME .readlines ()[0 ].rsplit (": " )[1 ].rsplit (
8380 " (" )[0 ].lstrip ("\n " ).replace (" " , "" ) # Parse the GUID
84- switch_to = list (
85- {val for key , val in windows_plan_map .items () if val != pwr_guid })[0 ]
86- print (switch_to , "switch to guid" )
8781 print (pwr_guid , "power guid" )
88- print (self .active_plan_map )
89- self .set_power_plan (switch_to )
90- time .sleep (.25 )
91- self .set_power_plan (pwr_guid )
9282 if state is True : # Activate boost
9383 self .do_boost (state )
9484 if notification is True :
@@ -104,15 +94,11 @@ def set_boost(self, state, notification=True):
10494 elif state == 4 :
10595 self .do_boost (state )
10696 if notification is True :
107- # Inform the user
108- self .notify ("Boost set to Efficient Aggressive" )
97+ self .notify ("Boost: Efficient Aggressive" ) # Inform the user
10998 elif state == 2 :
11099 self .do_boost (state )
111100 if notification is True :
112- self .notify ("Boost set to Aggressive" ) # Inform the user
113- self .set_power_plan (switch_to )
114- time .sleep (0.25 )
115- self .set_power_plan (pwr_guid )
101+ self .notify ("Boost: Aggressive" ) # Inform the user
116102
117103 def get_dgpu (self ):
118104 # I know, it's ugly, but no other way to do that from py.
@@ -132,7 +118,6 @@ def get_dgpu(self):
132118 return True
133119
134120 def set_dgpu (self , state , notification = True ):
135- config = self .config
136121 G14dir = self .G14dir
137122 # Just to be safe, let's get the current power scheme
138123 current_pwr = os .popen ("powercfg /GETACTIVESCHEME" )
@@ -235,6 +220,11 @@ def set_power_plan(self, GUID):
235220 if self .config ['debug' ]:
236221 print ('Set power result (good if nothing): ' , result )
237222
223+ def finalize_powercfg_chg (self , GUID ):
224+ time .sleep (.25 )
225+ subprocess .Popen (['powercfg' , '-setactive' , GUID ], shell = True ,
226+ creationflags = subprocess .CREATE_NO_WINDOW , stderr = STDOUT )
227+
238228 def apply_plan (self , plan ):
239229 current_plan = plan ['name' ]
240230 self .set_atrofac (plan ['plan' ], plan ['cpu_curve' ], plan ['gpu_curve' ])
0 commit comments