59
59
auto_cpufreq_stats_file = None
60
60
61
61
# track governor override
62
- STORE = "/opt/auto-cpufreq/override.pickle"
62
+ if os .getenv ("PKG_MARKER" ) == "SNAP" :
63
+ governor_override_state = Path ("/var/snap/auto-cpufreq/current/override.pickle" )
64
+ else :
65
+ governor_override_state = Path ("/opt/auto-cpufreq/current/override.pickle" )
63
66
64
67
if os .getenv ("PKG_MARKER" ) == "SNAP" :
65
68
auto_cpufreq_stats_path = Path ("/var/snap/auto-cpufreq/current/auto-cpufreq.stats" )
@@ -86,20 +89,20 @@ def get_config(config_file=""):
86
89
return get_config .config
87
90
88
91
def get_override ():
89
- if os .path .isfile (STORE ):
90
- with open (STORE , "rb" ) as store :
92
+ if os .path .isfile (governor_override_state ):
93
+ with open (governor_override_state , "rb" ) as store :
91
94
return pickle .load (store )
92
95
else :
93
96
return "default"
94
97
95
98
def set_override (override ):
96
99
if override in ["powersave" , "performance" ]:
97
- with open (STORE , "wb" ) as store :
100
+ with open (governor_override_state , "wb" ) as store :
98
101
pickle .dump (override , store )
99
102
print (f"Set governor override to { override } " )
100
103
elif override == "reset" :
101
- if os .path .isfile (STORE ):
102
- os .remove (STORE )
104
+ if os .path .isfile (governor_override_state ):
105
+ os .remove (governor_override_state )
103
106
print ("Governor override removed" )
104
107
elif override is not None :
105
108
print ("Invalid option.\n Use force=performance, force=powersave, or force=reset" )
@@ -367,6 +370,7 @@ def deploy_daemon():
367
370
bluetooth_disable ()
368
371
369
372
auto_cpufreq_stats_path .touch (exist_ok = True )
373
+ governor_override_state .touch (exist_ok = True )
370
374
371
375
print ("\n * Deploy auto-cpufreq install script" )
372
376
shutil .copy (SCRIPTS_DIR / "auto-cpufreq-install.sh" , "/usr/local/bin/auto-cpufreq-install" )
@@ -442,8 +446,8 @@ def remove_daemon():
442
446
os .remove ("/usr/local/bin/auto-cpufreq-remove" )
443
447
444
448
# delete override pickle if it exists
445
- if os .path .exists (STORE ):
446
- os .remove (STORE )
449
+ if os .path .exists (governor_override_state ):
450
+ os .remove (governor_override_state )
447
451
448
452
# delete stats file
449
453
if auto_cpufreq_stats_path .exists ():
0 commit comments