2021-01-24 13:47:01 +00:00
|
|
|
diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py
|
2021-02-10 00:12:43 +00:00
|
|
|
index a685db8..1ca1ca1 100644
|
2021-01-24 13:47:01 +00:00
|
|
|
--- a/auto_cpufreq/core.py
|
|
|
|
+++ b/auto_cpufreq/core.py
|
2021-02-10 00:12:43 +00:00
|
|
|
@@ -72,7 +72,7 @@ def app_version():
|
|
|
|
print("Git commit:", check_output(["git", "describe", "--always"]).strip().decode())
|
|
|
|
else:
|
|
|
|
print(getoutput("pacman -Qi auto-cpufreq | grep Version"))
|
|
|
|
- else:
|
|
|
|
+ else:
|
|
|
|
# source code (auto-cpufreq-installer)
|
|
|
|
try:
|
|
|
|
print("Git commit:", check_output(["git", "describe", "--always"]).strip().decode())
|
|
|
|
@@ -179,31 +179,13 @@ def get_current_gov():
|
2021-01-24 13:47:01 +00:00
|
|
|
return print("Currently using:", getoutput("cpufreqctl.auto-cpufreq --governor").strip().split(" ")[0], "governor")
|
2020-12-15 21:47:51 +00:00
|
|
|
|
2021-01-24 13:47:01 +00:00
|
|
|
def cpufreqctl():
|
|
|
|
- """
|
|
|
|
- deploy cpufreqctl script
|
|
|
|
- """
|
2020-12-15 21:47:51 +00:00
|
|
|
-
|
|
|
|
- # detect if running on a SNAP
|
|
|
|
- if os.getenv('PKG_MARKER') == "SNAP":
|
|
|
|
- pass
|
|
|
|
- else:
|
2021-01-24 13:47:01 +00:00
|
|
|
- # deploy cpufreqctl.auto-cpufreq script
|
2020-12-15 21:47:51 +00:00
|
|
|
- if os.path.isfile("/usr/bin/cpufreqctl"):
|
2021-01-24 13:47:01 +00:00
|
|
|
- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl.auto-cpufreq")
|
2020-12-15 21:47:51 +00:00
|
|
|
- else:
|
2021-01-24 13:47:01 +00:00
|
|
|
- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/bin/cpufreqctl.auto-cpufreq")
|
2020-12-15 21:47:51 +00:00
|
|
|
+ # scripts are already in the correct place
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
|
|
|
|
def cpufreqctl_restore():
|
2021-01-24 13:47:01 +00:00
|
|
|
- """
|
|
|
|
- remove cpufreqctl.auto-cpufreq script
|
|
|
|
- """
|
2020-12-15 21:47:51 +00:00
|
|
|
- # detect if running on a SNAP
|
|
|
|
- if os.getenv('PKG_MARKER') == "SNAP":
|
|
|
|
- pass
|
|
|
|
- else:
|
2021-01-24 13:47:01 +00:00
|
|
|
- if os.path.isfile("/usr/bin/cpufreqctl.auto-cpufreq"):
|
|
|
|
- os.remove("/usr/bin/cpufreqctl.auto-cpufreq")
|
2020-12-15 21:47:51 +00:00
|
|
|
+ # no need to restore
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
def footer(l=79):
|
2021-01-24 13:47:01 +00:00
|
|
|
print("\n" + "-" * l + "\n")
|
2021-02-10 00:12:43 +00:00
|
|
|
@@ -233,74 +215,12 @@ def remove_complete_msg():
|
|
|
|
footer()
|
2020-12-15 21:47:51 +00:00
|
|
|
|
|
|
|
def deploy_daemon():
|
|
|
|
- print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon " + "-" * 22 + "\n")
|
|
|
|
-
|
|
|
|
- # deploy cpufreqctl script func call
|
|
|
|
- cpufreqctl()
|
|
|
|
-
|
|
|
|
- print("* Turn off bluetooth on boot")
|
|
|
|
- btconf = Path("/etc/bluetooth/main.conf")
|
|
|
|
- try:
|
|
|
|
- orig_set = "AutoEnable=true"
|
|
|
|
- change_set = "AutoEnable=false"
|
|
|
|
- with btconf.open(mode="r+") as f:
|
|
|
|
- content = f.read()
|
|
|
|
- f.seek(0)
|
|
|
|
- f.truncate()
|
|
|
|
- f.write(content.replace(orig_set, change_set))
|
|
|
|
- except:
|
|
|
|
- print("\nERROR:\nWas unable to turn off bluetooth on boot")
|
|
|
|
-
|
2021-02-10 00:12:43 +00:00
|
|
|
- auto_cpufreq_stats_path.touch(exist_ok=True)
|
2020-12-15 21:47:51 +00:00
|
|
|
-
|
|
|
|
- print("\n* Deploy auto-cpufreq install script")
|
|
|
|
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install")
|
|
|
|
-
|
|
|
|
- print("\n* Deploy auto-cpufreq remove script")
|
|
|
|
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/bin/auto-cpufreq-remove")
|
|
|
|
-
|
|
|
|
- call("/usr/bin/auto-cpufreq-install", shell=True)
|
2021-01-24 13:47:01 +00:00
|
|
|
-
|
2020-12-15 21:47:51 +00:00
|
|
|
+ # prevent needless copying and system changes
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
# remove auto-cpufreq daemon
|
|
|
|
def remove():
|
|
|
|
-
|
|
|
|
- # check if auto-cpufreq is installed
|
|
|
|
- if not os.path.exists("/usr/bin/auto-cpufreq-remove"):
|
|
|
|
- print("\nauto-cpufreq daemon is not installed.\n")
|
|
|
|
- sys.exit(1)
|
2021-01-24 13:47:01 +00:00
|
|
|
-
|
2020-12-15 21:47:51 +00:00
|
|
|
- print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n")
|
|
|
|
-
|
|
|
|
- print("* Turn on bluetooth on boot")
|
|
|
|
- btconf = "/etc/bluetooth/main.conf"
|
|
|
|
- try:
|
|
|
|
- orig_set = "AutoEnable=true"
|
|
|
|
- change_set = "AutoEnable=false"
|
|
|
|
- with open(btconf, "r+") as f:
|
|
|
|
- content = f.read()
|
|
|
|
- f.seek(0)
|
|
|
|
- f.truncate()
|
|
|
|
- f.write(content.replace(change_set, orig_set))
|
|
|
|
- except:
|
|
|
|
- print("\nERROR:\nWas unable to turn on bluetooth on boot")
|
|
|
|
-
|
|
|
|
- # run auto-cpufreq daemon install script
|
|
|
|
- call("/usr/bin/auto-cpufreq-remove", shell=True)
|
|
|
|
-
|
|
|
|
- # remove auto-cpufreq-remove
|
|
|
|
- os.remove("/usr/bin/auto-cpufreq-remove")
|
|
|
|
-
|
2021-02-10 00:12:43 +00:00
|
|
|
- # delete stats file
|
|
|
|
- if auto_cpufreq_stats_path.exists():
|
|
|
|
- if auto_cpufreq_stats_file is not None:
|
|
|
|
- auto_cpufreq_stats_file.close()
|
2021-01-24 13:47:01 +00:00
|
|
|
-
|
2021-02-10 00:12:43 +00:00
|
|
|
- auto_cpufreq_stats_path.unlink()
|
2020-12-15 21:47:51 +00:00
|
|
|
-
|
|
|
|
- # restore original cpufrectl script
|
|
|
|
- cpufreqctl_restore()
|
|
|
|
-
|
|
|
|
+ pass
|
|
|
|
|
|
|
|
def gov_check():
|
|
|
|
for gov in get_avail_gov():
|
2021-02-10 00:12:43 +00:00
|
|
|
@@ -331,7 +251,7 @@ def countdown(s):
|
|
|
|
if auto_cpufreq_stats_file is not None:
|
|
|
|
auto_cpufreq_stats_file.seek(0)
|
|
|
|
auto_cpufreq_stats_file.truncate(0)
|
|
|
|
-
|
|
|
|
+
|
|
|
|
# execution timestamp
|
|
|
|
from datetime import datetime
|
|
|
|
now = datetime.now()
|
2021-01-24 13:47:01 +00:00
|
|
|
diff --git a/scripts/cpufreqctl.sh b/scripts/cpufreqctl.sh
|
|
|
|
index 63a2b5b..e157efe 100755
|
|
|
|
--- a/scripts/cpufreqctl.sh
|
|
|
|
+++ b/scripts/cpufreqctl.sh
|
|
|
|
@@ -467,35 +467,21 @@ fi
|
|
|
|
|
|
|
|
if [ $OPTION = "--install" ]
|
|
|
|
then
|
|
|
|
- echo 'installing helpers...'
|
|
|
|
- cp $0 /usr/bin/
|
|
|
|
- echo 'installing policy...'
|
|
|
|
- cp $(dirname "$(readlink -f "$0")")/konkor.cpufreq.policy /usr/share/polkit-1/actions/
|
|
|
|
- echo 'installing fonts...'
|
|
|
|
- mkdir -p /usr/share/fonts/truetype/cpufreq
|
|
|
|
- cp $(dirname "$(readlink -f "$0")")/fonts/cpufreq.ttf /usr/share/fonts/truetype/cpufreq/
|
|
|
|
- echo "done"
|
|
|
|
+ echo "install is disabled in the nix package"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ $OPTION = "--update-fonts" ]
|
|
|
|
then
|
|
|
|
- fc-cache -f
|
|
|
|
+ echo "update-fonts is disabled in the nix package"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ $OPTION = "--uninstall" ]
|
|
|
|
then
|
|
|
|
- echo 'uninstalling cpufreqctl helper...'
|
|
|
|
- rm /usr/bin/cpufreqctl
|
|
|
|
- echo 'uninstalling policy...'
|
|
|
|
- rm /usr/share/polkit-1/actions/konkor.cpufreq.policy
|
|
|
|
- echo 'uninstalling fonts...'
|
|
|
|
- rm -rf /usr/share/fonts/truetype/cpufreq
|
|
|
|
- echo "done"
|
|
|
|
+ echo "uninstall is disabled in the nix package"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ $OPTION = "--reset" ]
|
|
|
|
then
|
|
|
|
- echo 'reset to default values...'
|
|
|
|
- dconf reset -f "/org/gnome/shell/extensions/cpufreq/"
|
|
|
|
+ echo "reset is disabled in the nix package"
|
|
|
|
exit
|
|
|
|
fi
|