File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ """power_profile.py -- Switch CPU power profile"""
3+ import subprocess , argparse
4+
5+ PROFILES = {
6+ "performance" : ("performance" , "0" , "100" ),
7+ "balanced" : ("schedutil" , "85" , "10" ),
8+ "powersave" : ("powersave" , "100" , "2" ),
9+ }
10+
11+ def adb (cmd ):
12+ subprocess .run (f"adb shell { cmd } " , shell = True , capture_output = True )
13+
14+ def set_profile (mode ):
15+ if mode not in PROFILES :
16+ print (f"Unknown: { mode } " )
17+ return
18+ gov , headroom , rate = PROFILES [mode ]
19+ adb (f"echo { gov } > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" )
20+ print (f"CPU profile: { mode } " )
21+
22+ if __name__ == "__main__" :
23+ parser = argparse .ArgumentParser ()
24+ parser .add_argument ("--mode" , default = "balanced" , choices = PROFILES .keys ())
25+ set_profile (parser .parse_args ().mode )
You can’t perform that action at this time.
0 commit comments