Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Angel-Karasu committed Jul 9, 2024
1 parent 6d2362f commit e8e053f
Showing 1 changed file with 24 additions and 40 deletions.
64 changes: 24 additions & 40 deletions nix/patches/prevent-install-and-copy.patch
Original file line number Diff line number Diff line change
@@ -1,85 +1,73 @@
diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py
index ba11f52..f7a43d8 100755
index 6ee9986..5015982 100755
--- a/auto_cpufreq/core.py
+++ b/auto_cpufreq/core.py
@@ -377,25 +377,13 @@ def get_current_gov():

@@ -260,18 +260,12 @@ def get_current_gov():
)

def cpufreqctl():
- """
- deploy cpufreqctl script
- deploy cpufreqctl.auto-cpufreq script
- """
-
- # detect if running on a SNAP
- if not IS_INSTALLED_WITH_SNAP:
- # deploy cpufreqctl.auto-cpufreq script
- if not os.path.isfile("/usr/local/bin/cpufreqctl.auto-cpufreq"):
- shutil.copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/local/bin/cpufreqctl.auto-cpufreq")
- if not (IS_INSTALLED_WITH_SNAP or os.path.isfile("/usr/local/bin/cpufreqctl.auto-cpufreq")):
- copy(SCRIPTS_DIR / "cpufreqctl.sh", "/usr/local/bin/cpufreqctl.auto-cpufreq")
+ # scripts are already in the correct place
+ pass


def cpufreqctl_restore():
- """
- remove cpufreqctl.auto-cpufreq script
- """
- # detect if running on a SNAP
- if not IS_INSTALLED_WITH_SNAP:
- if os.path.isfile("/usr/local/bin/cpufreqctl.auto-cpufreq"):
- os.remove("/usr/local/bin/cpufreqctl.auto-cpufreq")
- if not IS_INSTALLED_WITH_SNAP and os.path.isfile("/usr/local/bin/cpufreqctl.auto-cpufreq"):
- os.remove("/usr/local/bin/cpufreqctl.auto-cpufreq")
+ #no need to restore
+ pass

def footer(l=79): print("\n" + "-" * l + "\n")

def footer(l=79):
@@ -423,30 +411,8 @@ def remove_complete_msg():

@@ -287,27 +281,8 @@ def remove_complete_msg():
footer()

def deploy_daemon():
- print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon " + "-" * 22 + "\n")
-
- # deploy cpufreqctl script func call
- cpufreqctl()
- cpufreqctl() # deploy cpufreqctl script func call
-
- # turn off bluetooth on boot
- bluetooth_disable()
- bluetooth_disable() # turn off bluetooth on boot
-
- auto_cpufreq_stats_path.touch(exist_ok=True)
-
- print("\n* Deploy auto-cpufreq install script")
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/local/bin/auto-cpufreq-install")
- copy(SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/local/bin/auto-cpufreq-install")
-
- print("\n* Deploy auto-cpufreq remove script")
- shutil.copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/local/bin/auto-cpufreq-remove")
- copy(SCRIPTS_DIR / "auto-cpufreq-remove.sh", "/usr/local/bin/auto-cpufreq-remove")
-
- # output warning if gnome power profile is running
- gnome_power_detect_install()
- gnome_power_svc_disable()
-
- # output warning if TLP service is detected
- tlp_service_detect()
- tlp_service_detect() # output warning if TLP service is detected
-
- call("/usr/local/bin/auto-cpufreq-install", shell=True)
+ # prevent needless copying and system changes
+ pass


def deploy_daemon_performance():
@@ -485,41 +451,7 @@ def deploy_daemon_performance():
print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon (performance) " + "-" * 22 + "\n")
@@ -339,35 +314,7 @@ def deploy_daemon_performance():

call("/usr/local/bin/auto-cpufreq-install", shell=True)

# remove auto-cpufreq daemon
-def remove_daemon():
-
- # check if auto-cpufreq is installed
- if not os.path.exists("/usr/local/bin/auto-cpufreq-remove"):
- print("\nauto-cpufreq daemon is not installed.\n")
- sys.exit(1)
-
- print("\n" + "-" * 21 + " Removing auto-cpufreq daemon " + "-" * 22 + "\n")
-
- # turn on bluetooth on boot
- bluetooth_enable()
- bluetooth_enable() # turn on bluetooth on boot
-
- # output warning if gnome power profile is stopped
- gnome_power_rm_reminder()
Expand All @@ -92,19 +80,15 @@ index ba11f52..f7a43d8 100755
- os.remove("/usr/local/bin/auto-cpufreq-remove")
-
- # delete override pickle if it exists
- if os.path.exists(governor_override_state):
- os.remove(governor_override_state)
- if os.path.exists(governor_override_state): os.remove(governor_override_state)
-
- # delete stats file
- if auto_cpufreq_stats_path.exists():
- if auto_cpufreq_stats_file is not None:
- auto_cpufreq_stats_file.close()
-
- if auto_cpufreq_stats_file is not None: auto_cpufreq_stats_file.close()
- auto_cpufreq_stats_path.unlink()
-
- # restore original cpufrectl script
- cpufreqctl_restore()
- cpufreqctl_restore() # restore original cpufrectl script
+def remove_daemon(): pass


def gov_check():
for gov in AVAILABLE_GOVERNORS:

0 comments on commit e8e053f

Please sign in to comment.