@@ -40,10 +40,7 @@ def parse_boolean(self, parse_string):
40
40
41
41
def get_boost (self ):
42
42
# 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
47
44
SUB_PROCESSOR = " 54533251-82be-4824-96c1-47b60b740d00"
48
45
PERFBOOSTMODE = " be337238-0d82-4146-a960-4f3749d470c7"
49
46
# Let's get the boost option in the currently active power scheme
@@ -58,14 +55,11 @@ def get_boost(self):
58
55
59
56
def do_boost (self , state ):
60
57
# Just to be safe, let's get the current power scheme
61
- CURRENT_SCHEME = os .popen ("powercfg /GETACTIVESCHEME" )
62
58
SUB_PROCESSOR = "54533251-82be-4824-96c1-47b60b740d00"
63
59
PERFBOOSTMODE = "be337238-0d82-4146-a960-4f3749d470c7"
64
60
set_ac = "powercfg /setacvalueindex"
65
61
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 ]
69
63
if state is False :
70
64
state = 0
71
65
SET_AC_VAL = "{0} {1} {2} {3} {4}" .format (
@@ -128,16 +122,11 @@ def set_boost(self, state, notification=True):
128
122
129
123
def get_dgpu (self ):
130
124
# 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
135
126
SW_DYNAMC_GRAPHICS = "e276e160-7cb0-43c6-b20b-73f5dce39954"
136
127
GLOBAL_SETTINGS = "a1662ab2-9d34-4e53-ba8b-2639b9e20857"
137
128
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 ])
141
130
) # Let's get the dGPU status in the current power scheme
142
131
output = pwr_settings .readlines () # We save the output to parse it afterwards
143
132
# Convert to boolean for "On/Off"
@@ -150,8 +139,7 @@ def get_dgpu(self):
150
139
def set_dgpu (self , state , notification = True ):
151
140
G14dir = self .G14dir
152
141
# 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 ]
155
143
SW_DYNAMC_GRAPHICS = "e276e160-7cb0-43c6-b20b-73f5dce39954"
156
144
GLOBAL_SETTINGS = "a1662ab2-9d34-4e53-ba8b-2639b9e20857"
157
145
AC = "/setacvalueindex"
@@ -163,7 +151,7 @@ def _set_dgpu(SETTING, AC_DC):
163
151
[
164
152
"powercfg" ,
165
153
AC_DC ,
166
- CURRENT_GUID ,
154
+ pwr_guid ,
167
155
SW_DYNAMC_GRAPHICS ,
168
156
GLOBAL_SETTINGS ,
169
157
str (SETTING ),
0 commit comments