diff --git a/pkgs/by-name/au/auto-cpufreq/fix-version-output.patch b/pkgs/by-name/au/auto-cpufreq/fix-version-output.patch index be21ca889081d..dbb459b7fee95 100644 --- a/pkgs/by-name/au/auto-cpufreq/fix-version-output.patch +++ b/pkgs/by-name/au/auto-cpufreq/fix-version-output.patch @@ -1,33 +1,20 @@ -diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 58cedb7..89e77a4 100755 ---- a/auto_cpufreq/core.py -+++ b/auto_cpufreq/core.py -@@ -136,26 +136,8 @@ except PermissionError: - +diff --git c/auto_cpufreq/core.py i/auto_cpufreq/core.py +index b51d55d..b0bff1e 100755 +--- c/auto_cpufreq/core.py ++++ i/auto_cpufreq/core.py +@@ -96,13 +96,8 @@ except PermissionError: + # display running version of auto-cpufreq def app_version(): -- - print("auto-cpufreq version: ", end="") - -- # snap package -- if os.getenv("PKG_MARKER") == "SNAP": -- print(getoutput(r"echo \(Snap\) $SNAP_VERSION")) -- # aur package -- elif dist_name in ["arch", "manjaro", "garuda"]: -- aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True) -- if aur_pkg_check == 1: -- print(get_formatted_version()) -- else: -- print(getoutput("pacman -Qi auto-cpufreq | grep Version")) +- if IS_INSTALLED_WITH_SNAP: print(getoutput(r"echo \(Snap\) $SNAP_VERSION")) +- elif IS_INSTALLED_WITH_AUR: print(getoutput("pacman -Qi auto-cpufreq | grep Version")) - else: -- # source code (auto-cpufreq-installer) -- try: -- print(get_formatted_version()) -- except Exception as e: -- print(repr(e)) -- pass -+ print("auto-cpufreq version: @version@") -+ print("Git commit: v@version@") - +- try: print(get_formatted_version()) +- except Exception as e: print(repr(e)) ++ print("auto-cpufreq version: @version@") ++ print("Git commit: v@version@") + def check_for_update(): # returns True if a new release is available from the GitHub repo diff --git a/pkgs/by-name/au/auto-cpufreq/package.nix b/pkgs/by-name/au/auto-cpufreq/package.nix index bfc4d29632366..244735554010a 100644 --- a/pkgs/by-name/au/auto-cpufreq/package.nix +++ b/pkgs/by-name/au/auto-cpufreq/package.nix @@ -9,14 +9,14 @@ }: python3Packages.buildPythonPackage rec { pname = "auto-cpufreq"; - version = "2.3.0"; + version = "2.4.0"; format = "pyproject"; src = fetchFromGitHub { owner = "AdnanHodzic"; repo = "auto-cpufreq"; - rev = "v${version}"; - hash = "sha256-Bet/WOVveLIA+0Mvly4AsielR+r/AJXIgHdWrtc7i/U="; + rev = "refs/tags/v${version}"; + hash = "sha256-Xsh3d7rQY7RKzZ7J0swrgxZEyITb7B3oX5F/tcBGjfk="; }; nativeBuildInputs = [ diff --git a/pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch b/pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch index 2b3c9de1b6b07..bf4987f8117b0 100644 --- a/pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch +++ b/pkgs/by-name/au/auto-cpufreq/prevent-install-and-copy.patch @@ -1,13 +1,13 @@ -diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py -index 4343b8d..dc286f6 100755 ---- a/auto_cpufreq/bin/auto_cpufreq.py -+++ b/auto_cpufreq/bin/auto_cpufreq.py -@@ -199,41 +199,9 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta - print("https://github.com/AdnanHodzic/auto-cpufreq/#donate") - footer() +diff --git c/auto_cpufreq/bin/auto_cpufreq.py i/auto_cpufreq/bin/auto_cpufreq.py +index 7192366..96289e1 100755 +--- c/auto_cpufreq/bin/auto_cpufreq.py ++++ i/auto_cpufreq/bin/auto_cpufreq.py +@@ -134,20 +134,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g + except KeyboardInterrupt: break + conf.notifier.stop() elif install: -- if os.getenv("PKG_MARKER") == "SNAP": -- root_check() +- root_check() +- if IS_INSTALLED_WITH_SNAP: - running_daemon_check() - gnome_power_detect_snap() - tlp_service_detect_snap() @@ -15,17 +15,21 @@ index 4343b8d..dc286f6 100755 - gov_check() - run("snapctl set daemon=enabled", shell=True) - run("snapctl start --enable auto-cpufreq", shell=True) -- deploy_complete_msg() - else: -- root_check() - running_daemon_check() - gov_check() - deploy_daemon() -- deploy_complete_msg() +- deploy_complete_msg() + print("install is disabled in the nix package") + elif update: + root_check() + custom_dir = "/opt/auto-cpufreq/source" +@@ -185,21 +172,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g + run(["auto-cpufreq", "--version"]) + else: print("Aborted") elif remove: -- if os.getenv("PKG_MARKER") == "SNAP": -- root_check() +- root_check() +- if IS_INSTALLED_WITH_SNAP: - run("snapctl set daemon=disabled", shell=True) - run("snapctl stop --disable auto-cpufreq", shell=True) - if auto_cpufreq_stats_path.exists(): @@ -37,92 +41,73 @@ index 4343b8d..dc286f6 100755 - # {the following snippet also used in --update, update it there too(if required)} - # * undo bluetooth boot disable - gnome_power_rm_reminder_snap() -- remove_complete_msg() -- else: -- root_check() -- remove_daemon() -- remove_complete_msg() +- else: remove_daemon() +- remove_complete_msg() + print("remove is disabled in the nix package") - elif update: - root_check() - custom_dir = "/opt/auto-cpufreq/source" -diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 58cedb7..c50b0e1 100755 ---- a/auto_cpufreq/core.py -+++ b/auto_cpufreq/core.py -@@ -391,30 +391,13 @@ def get_current_gov(): - + elif stats: + not_running_daemon_check() + config_info_dialog() +diff --git c/auto_cpufreq/core.py i/auto_cpufreq/core.py +index b51d55d..4e4b5d3 100755 +--- c/auto_cpufreq/core.py ++++ i/auto_cpufreq/core.py +@@ -277,18 +277,12 @@ def get_current_gov(): + ) def cpufreqctl(): - """ -- deploy cpufreqctl script +- deploy cpufreqctl.auto-cpufreq script - """ -- -- # detect if running on a SNAP -- if os.getenv("PKG_MARKER") == "SNAP": -- pass -- else: -- # 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 os.getenv("PKG_MARKER") == "SNAP": -- pass -- else: -- 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") -@@ -441,30 +424,8 @@ def remove_complete_msg(): + def footer(l=79): print("\n" + "-" * l + "\n") +@@ -306,27 +300,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(): -@@ -504,40 +465,7 @@ def deploy_daemon_performance(): + print("\n" + "-" * 21 + " Deploying auto-cpufreq as a daemon (performance) " + "-" * 22 + "\n") +@@ -359,34 +334,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") @@ -130,8 +115,7 @@ index 58cedb7..c50b0e1 100755 - - 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() @@ -144,19 +128,15 @@ index 58cedb7..c50b0e1 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 + pass - def gov_check(): + for gov in AVAILABLE_GOVERNORS: diff --git a/pkgs/by-name/au/auto-cpufreq/prevent-update.patch b/pkgs/by-name/au/auto-cpufreq/prevent-update.patch index 840c7230313d7..b9119540b80fc 100644 --- a/pkgs/by-name/au/auto-cpufreq/prevent-update.patch +++ b/pkgs/by-name/au/auto-cpufreq/prevent-update.patch @@ -1,10 +1,10 @@ -diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py -index 4343b8d..183c2e9 100755 ---- a/auto_cpufreq/bin/auto_cpufreq.py -+++ b/auto_cpufreq/bin/auto_cpufreq.py -@@ -235,47 +235,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta - remove_daemon() - remove_complete_msg() +diff --git c/auto_cpufreq/bin/auto_cpufreq.py i/auto_cpufreq/bin/auto_cpufreq.py +index 7192366..0bf087e 100755 +--- c/auto_cpufreq/bin/auto_cpufreq.py ++++ i/auto_cpufreq/bin/auto_cpufreq.py +@@ -149,41 +149,7 @@ def main(monitor, live, daemon, install, update, remove, force, config, stats, g + deploy_daemon() + deploy_complete_msg() elif update: - root_check() - custom_dir = "/opt/auto-cpufreq/source" @@ -16,27 +16,22 @@ index 4343b8d..183c2e9 100755 - if "--update" in sys.argv: - update = True - sys.argv.remove("--update") -- if len(sys.argv) == 2: -- custom_dir = sys.argv[1] +- if len(sys.argv) == 2: custom_dir = sys.argv[1] - -- if os.getenv("PKG_MARKER") == "SNAP": +- if IS_INSTALLED_WITH_SNAP: - print("Detected auto-cpufreq was installed using snap") - # refresh snap directly using this command - # path wont work in this case - - print("Please update using snap package manager, i.e: `sudo snap refresh auto-cpufreq`.") - #check for AUR -- elif subprocess.run(["bash", "-c", "command -v pacman >/dev/null 2>&1"]).returncode == 0 and subprocess.run(["bash", "-c", "pacman -Q auto-cpufreq >/dev/null 2>&1"]).returncode == 0: -- print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") +- elif IS_INSTALLED_WITH_AUR: print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") - else: - is_new_update = check_for_update() -- if not is_new_update: -- return +- if not is_new_update: return - ans = input("Do you want to update auto-cpufreq to the latest release? [Y/n]: ").strip().lower() -- if not os.path.exists(custom_dir): -- os.makedirs(custom_dir) -- if os.path.exists(os.path.join(custom_dir, "auto-cpufreq")): -- shutil.rmtree(os.path.join(custom_dir, "auto-cpufreq")) +- if not os.path.exists(custom_dir): os.makedirs(custom_dir) +- if os.path.exists(os.path.join(custom_dir, "auto-cpufreq")): rmtree(os.path.join(custom_dir, "auto-cpufreq")) - if ans in ['', 'y', 'yes']: - remove_daemon() - remove_complete_msg() @@ -45,28 +40,28 @@ index 4343b8d..183c2e9 100755 - run(["auto-cpufreq", "--install"]) - print("auto-cpufreq is installed with the latest version") - run(["auto-cpufreq", "--version"]) -- else: -- print("Aborted") +- else: print("Aborted") + print("update is disabled in the nix package") - - elif completions: - if completions == "bash": -diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 58cedb7..8b44712 100755 ---- a/auto_cpufreq/core.py -+++ b/auto_cpufreq/core.py -@@ -17,8 +17,7 @@ import importlib.metadata - from math import isclose + elif remove: + root_check() + if IS_INSTALLED_WITH_SNAP: +diff --git c/auto_cpufreq/core.py i/auto_cpufreq/core.py +index b51d55d..99eeed8 100755 +--- c/auto_cpufreq/core.py ++++ i/auto_cpufreq/core.py +@@ -7,9 +7,8 @@ from math import isclose from pathlib import Path - from shutil import which --from subprocess import getoutput, call, run, check_output, DEVNULL --import requests -+from subprocess import getoutput, call, run, DEVNULL - import re + from pickle import dump, load + from re import search +-from requests import get, exceptions + from shutil import copy +-from subprocess import call, check_output, DEVNULL, getoutput, run ++from subprocess import call, DEVNULL, getoutput, run + from time import sleep + from warnings import filterwarnings - # execution timestamp used in countdown func -@@ -158,55 +157,7 @@ def app_version(): - pass +@@ -105,49 +104,7 @@ def app_version(): + except Exception as e: print(repr(e)) def check_for_update(): - # returns True if a new release is available from the GitHub repo @@ -74,21 +69,19 @@ index 58cedb7..8b44712 100755 - # Specify the repository and package name - # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY - # Fetch the latest release information from GitHub API -- latest_release_url = f"https://api.github.com/repos/AdnanHodzic/auto-cpufreq/releases/latest" +- latest_release_url = GITHUB.replace("github.com", "api.github.com/repos") + "/releases/latest" - try: -- response = requests.get(latest_release_url) -- if response.status_code == 200: -- latest_release = response.json() +- response = get(latest_release_url) +- if response.status_code == 200: latest_release = response.json() - else: - message = response.json().get("message") - print("Error fetching recent release!") - if message is not None and message.startswith("API rate limit exceeded"): - print("GitHub Rate limit exceeded. Please try again later within 1 hour or use different network/VPN.") -- else: -- print("Unexpected status code:", response.status_code) +- else: print("Unexpected status code:", response.status_code) - return False -- except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, -- requests.exceptions.RequestException, requests.exceptions.HTTPError) as err: +- except (exceptions.ConnectionError, exceptions.Timeout, +- exceptions.RequestException, exceptions.HTTPError): - print("Error Connecting to server!") - return False - @@ -98,8 +91,7 @@ index 58cedb7..8b44712 100755 - # Get the current version of auto-cpufreq - # Extract version number from the output string - output = check_output(['auto-cpufreq', '--version']).decode('utf-8') -- try: -- version_line = next((re.search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None) +- try: version_line = next((search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None) - except AttributeError: - print("Error Retrieving Current Version!") - exit(1) @@ -113,40 +105,31 @@ index 58cedb7..8b44712 100755 - print(f"Updates are available,\nCurrent version: {installed_version}\nLatest version: {latest_version}") - print("Note that your previous custom settings might be erased with the following update") - return True -- else: -- # Handle the case where "tag_name" key doesn't exist -- print("Malformed Released data!\nReinstall manually or Open an issue on GitHub for help!") -- -- +- # Handle the case where "tag_name" key doesn't exist +- else: print("Malformed Released data!\nReinstall manually or Open an issue on GitHub for help!") + pass def new_update(custom_dir): os.chdir(custom_dir) -diff --git a/poetry.lock b/poetry.lock -index 2a99ca6..9bc26e2 100644 ---- a/poetry.lock -+++ b/poetry.lock -@@ -1,4 +1,4 @@ --# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. -+# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. - - [[package]] - name = "attrs" -@@ -1300,4 +1300,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p +diff --git c/poetry.lock i/poetry.lock +index 0e6da84..b4936fe 100644 +--- c/poetry.lock ++++ i/poetry.lock +@@ -1306,4 +1306,4 @@ test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-it [metadata] lock-version = "2.0" python-versions = "^3.8" --content-hash = "ee73b2db6a43cac87120f38c93d0a8a297bec52f1346b55bc0ca2992aa464482" -+content-hash = "1ba0c404ffea01a611e7c74f9c104de44a914b0a6fad2350470f15880931ae42" -diff --git a/pyproject.toml b/pyproject.toml -index 876d80c..7190356 100644 ---- a/pyproject.toml -+++ b/pyproject.toml +-content-hash = "cad3783d04e35b66b241352e76631d0a83c8df3d286b113979ba34a65847f06c" ++content-hash = "b21af52156d2d624602fe6941cf001abd7f8cf5b70b22ebfd7b7ad0dece1e39f" +diff --git c/pyproject.toml i/pyproject.toml +index 562a94b..cc44d8d 100644 +--- c/pyproject.toml ++++ i/pyproject.toml @@ -25,7 +25,6 @@ python = "^3.8" - psutil = {git = "https://github.com/giampaolo/psutil.git", rev = "4cf56e08c1bc883ec89758834b50954380759858"} + psutil = "^6.0.0" click = "^8.1.0" distro = "^1.8.0" --requests = "^2.31.0" +-requests = "^2.32.3" PyGObject = "^3.46.0" pyinotify = {git = "https://github.com/shadeyg56/pyinotify-3.12"}