Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update feature added #526

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .github/FUNDING.yml
100644 → 100755
Empty file.
Empty file modified .github/issue_template.md
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
72 changes: 55 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ auto-cpufreq is looking for [co-maintainers & open source developers to help sha
* [Snap store](#snap-store)
* [auto-cpufreq-installer](#auto-cpufreq-installer)
* [AUR package (Arch/Manjaro Linux)](#aur-package-archmanjaro-linux)
* [Update using installer](#update-using-auto-cpufreq-installer)
* [Post Installation](#post-installation)
* [Configuring auto-cpufreq](#configuring-auto-cpufreq)
* [1: power_helper.py script (Snap package install only)](#1-power_helperpy-script-snap-package-install-only)
Expand All @@ -31,6 +32,7 @@ auto-cpufreq is looking for [co-maintainers & open source developers to help sha
* [live](#live)
* [overriding governor](#overriding-governor)
* [Install - auto-cpufreq daemon](#install---auto-cpufreq-daemon)
* [Update - auto-cpufreq update](#update---auto-cpufreq-update)
* [Remove - auto-cpufreq daemon](#remove---auto-cpufreq-daemon)
* [stats](#stats)
* [Troubleshooting](#troubleshooting)
Expand Down Expand Up @@ -86,10 +88,10 @@ auto-cpufreq is available on the [snap store](https://snapcraft.io/auto-cpufreq)
sudo snap install auto-cpufreq
```

**Please note:**
**Please note:**
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
* Make sure [snapd](https://snapcraft.io/docs/installing-snapd) is installed and `snap version` version is >= 2.44 for `auto-cpufreq` to fully work due to [recent snapd changes](https://github.com/snapcore/snapd/pull/8127).

* Fedora users will [encounter following error](https://twitter.com/killyourfm/status/1291697985236144130) due to `cgroups v2` [being in development](https://github.com/snapcore/snapd/pull/7825). This problem can be resolved by either running `sudo snap run auto-cpufreq` after the snap installation or by using the [auto-cpufreq-installer](#auto-cpufreq-installer) which doesn't have this issue.
* Fedora users will [encounter following error](https://twitter.com/killyourfm/status/1291697985236144130) due to `cgroups v2` [being in development](https://github.com/snapcore/snapd/pull/7825). This problem can be resolved by either running `sudo snap run auto-cpufreq` after the snap installation or by using the [auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer) which doesn't have this issue.
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

### auto-cpufreq-installer

Expand All @@ -99,12 +101,22 @@ Get source code, run installer and follow on screen instructions:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq && sudo ./auto-cpufreq-installer
```
### Update using auto-cpufreq-installer
AdnanHodzic marked this conversation as resolved.
Show resolved Hide resolved
* The feature is available from version *1.9.8*. If your current version is below the same, Get source code, run installer and follow on screen instructions:

```
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq && sudo ./auto-cpufreq-installer
```
and choose 'Update' option

For further information: [--update](#update---auto-cpufreq-update)

In case you encounter any problems with `auto-cpufreq-installer`, please [submit a bug report](https://github.com/AdnanHodzic/auto-cpufreq/issues/new).

### AUR package (Arch/Manjaro Linux)

*AUR is currently unmaintained & has issues*! Until someone starts maintaining it, use the [auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq#auto-cpufreq-installer) if you intend to have the latest changes as otherwise you'll run into errors, i.e: [#471](https://github.com/AdnanHodzic/auto-cpufreq/issues/471). However, if you still wish to use AUR then follow the [Troubleshooting](#aur) section for solved known issues.
*AUR is currently unmaintained & has issues*! Until someone starts maintaining it, use the [auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq#auto-cpufreq-installer) if you intend to have the latest changes as otherwise you'll run into errors, i.e: [#471](https://github.com/AdnanHodzic/auto-cpufreq/issues/471). However, if you still wish to use AUR then follow the [Troubleshooting](https://github.com/AdnanHodzic/auto-cpufreq/#aur) section for solved known issues.
AdnanHodzic marked this conversation as resolved.
Show resolved Hide resolved

* [Binary Package](https://aur.archlinux.org/packages/auto-cpufreq)
(For the latest binary release on github)
Expand All @@ -120,11 +132,11 @@ auto-cpufreq makes all decisions automatically based on various factors like cpu

### 1: power_helper.py script (Snap package install **only**)

When installing auto-cpufreq using [auto-cpufreq-installer](#auto-cpufreq-installer) if it detects [GNOME Power profiles service](https://twitter.com/fooctrl/status/1467469508373884933) is running it will automatically disable it. Otherwise this daemon will cause conflicts and various other performance issues.
When installing auto-cpufreq using [auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-installer) if it detects [GNOME Power profiles service](https://twitter.com/fooctrl/status/1467469508373884933) is running it will automatically disable it. Otherwise this daemon will cause conflicts and various other performance issues.
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

However, when auto-cpufreq is installed as Snap package it's running as part of a container with limited permissions to your host machine, hence it's *highly recommended* you disable GNOME Power Profiles Daemon using `power_helper.py` script.

**Please Note:**<br>
**Please Note:**
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
The [`power_helper.py`](https://github.com/AdnanHodzic/auto-cpufreq/blob/master/auto_cpufreq/power_helper.py) script is located at `auto_cpufreq/power_helper.py`. In order to have access to it, you need to first clone
the repository:

Expand All @@ -142,11 +154,11 @@ Then disable GNOME Power Profiles Daemon by runing:

### 2: `--force` governor override

By default auto-cpufreq uses `balanced` mode which works the best on various systems and situations.
By default auto-cpufreq uses `balanced` mode which works the best on various systems and situations.
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

However, you can override this behaviour by switching to `performance` or `powersave` mode manually. Performance will result in higher frequencies by default, but also results in higher energy use (battery consumption) and should be used if max performance is necessary. Otherwise `powersave` will do the opposite and extend the battery life to its maximum.

See [`--force` flag](#overriding-governor) for more info.
See [`--force` flag](https://github.com/AdnanHodzic/auto-cpufreq/#overriding-governor) for more info.
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

### 3: auto-cpufreq config file

Expand Down Expand Up @@ -202,22 +214,25 @@ turbo = auto
## How to run auto-cpufreq
auto-cpufreq should be run with with one of the following options:

* [monitor](#monitor)
* [monitor](https://github.com/AdnanHodzic/auto-cpufreq/#monitor)
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
- Monitor and see suggestions for CPU optimizations

* [live](#live)
* [live](https://github.com/AdnanHodzic/auto-cpufreq/#live)
- Monitor and make (temp.) suggested CPU optimizations

* [install](#install---auto-cpufreq-daemon) / [remove](#remove---auto-cpufreq-daemon)
* [install](https://github.com/AdnanHodzic/auto-cpufreq/#install---auto-cpufreq-daemon) / [remove](https://github.com/AdnanHodzic/auto-cpufreq/#remove---auto-cpufreq-daemon)
- Install/remove daemon for (permanent) automatic CPU optimizations

* [update](#update---auto-cpufreq-update)
- Update the package to the latest release

* [install_performance](#1-power_helperpy-script)
- Install daemon in "performance" mode.

* [stats](#stats)
* [stats](https://github.com/AdnanHodzic/auto-cpufreq/#stats)
- View live stats of CPU optimizations made by daemon

* [force=TEXT](#overriding-governor)
* [force=TEXT](https://github.com/AdnanHodzic/auto-cpufreq/#overriding-governor)
- Force use of either the "powersave" or "performance" governor. Setting to "reset" goes back to normal mode

* config=TEXT
Expand All @@ -229,13 +244,13 @@ auto-cpufreq should be run with with one of the following options:
* version
- Show currently installed version

* [donate](#financial-donation)
* [donate](https://github.com/AdnanHodzic/auto-cpufreq/#financial-donation)
- To support the project

* help
- Shows all of the above options

Running `auto-cpufreq --help` will print the same list of options as above. Read [auto-cpufreq modes and options](#auto-cpufreq-modes-and-options) for more details.
Running `auto-cpufreq --help` will print the same list of options as above. Read [auto-cpufreq modes and options](https://github.com/AdnanHodzic/auto-cpufreq/#auto-cpufreq-modes-and-options) for more details.
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

## auto-cpufreq modes and options

Expand Down Expand Up @@ -278,6 +293,29 @@ If the install has been performed as part of snap package, daemon status can be

`systemctl status snap.auto-cpufreq.service.service`

### Update - auto-cpufreq update

Update to the [latest version](https://github.com/AdnanHodzic/auto-cpufreq/releases) of auto-cpufreq with fixes and resolved bugs.

* If auto-cpufreq is not installed using `snapd`:
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

Manually clone auto-cpufreq to the latest release if this mode is not available in your package(follow [Installing auto-cpufreq](#installing-auto-cpufreq)

Update the package by running(available with both snapd and non-snapd packages):
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

`sudo auto-cpufreq --update`

This does the equivalent of:
* `systemctl stop auto-cpufreq && systemctl disable auto-cpufreq`
* Fetching new update and install
* `systemctl enable auto-cpufreq`

* For snap and AUR packages, run:
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

`sudo snap refresh auto-cpufreq`

daemon is automatically enabled after `refresh`

### Remove - auto-cpufreq daemon

auto-cpufreq daemon and its systemd service, along with all its persistent changes can be removed by running:
Expand Down Expand Up @@ -322,7 +360,7 @@ For AMD users:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash initcall_blacklist=amd_pstate_init amd_pstate.enable=0"
```

Once you have made the necessary changes to the GRUB configuration file, you can update it by running `sudo update-grub` or `sudo grub-mkconfig -o /boot/grub/grub.cfg` on Arch Linux. On the other hand, for Fedora, you can update the configuration file by running one of the following commands:
Once you have made the necessary changes to the GRUB configuration file, you can update it by running `sudo update-grub` or `sudo grub-mkconfig -o /boot/grub/grub.cfg` on Arch Linux. On the other hand, for Fedora, you can update the configuration file by running one of the following commands:
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

```
sudo grub2-mkconfig -o /etc/grub2.cfg
Expand All @@ -333,8 +371,8 @@ Once you have made the necessary changes to the GRUB configuration file, you can
```

```
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# Legacy boot method for grub update.
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
# Legacy boot method for grub update.
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
```

### AUR
Expand Down
56 changes: 53 additions & 3 deletions auto-cpufreq-installer
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function completed () {
echo -e "\nInstalling necessary Python packages\n"
setup_venv
separator
echo -e "\ninstalling auto-cpufreq tool\n"
echo -e "\n installing auto-cpufreq tool\n"
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
install
}

Expand Down Expand Up @@ -254,20 +254,65 @@ function tool_remove {
rm -rf "${venv_path}"

separator
echo -e "\nauto-cpufreq tool and all its supporting files successfully removed."
echo -e "\nauto-cpufreq tool and all its supporting files successfully removed."
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved
separator
}
function tool_update {
# Specify the repository and package name
# IT IS IMPORTANT TO NOTE THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY
repository="AdnanHodzic/auto-cpufreq"
# Fetch the latest release information from GitHub API
latest_release=$(curl -s "https://api.github.com/repos/$repository/releases/latest")
# Extract the latest release version without using jq
latest_version=$(echo "$latest_release" | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)
# Get the current version of auto-cpufreq
#installed_version=$(pip list | awk '/auto-cpufreq/ {print $2}')
installed_version=$(grep -oP "(?<=__requires__ = 'auto-cpufreq==)\d+(\.\d+)+" /opt/auto-cpufreq/venv/bin/auto-cpufreq)
#Check whether the same is installed or not
if [[ -z "$installed_version" ]]; then
echo "Current version not found, please install auto-cpufreq first"
echo $installed_version
sleep 1
exit 1
fi
installed_version="v$installed_version"
# Compare the latest version with the installed version and perform update if necessary
if [[ "$latest_version" == "$installed_version" ]]; then
echo "auto-cpufreq is up to date"
else
echo -e "Updates are available,\nCurrent version: $installed_version\nLatest version: $latest_version \nNote that your previous custom settings might be \033[1merased\033[0m with the following update \nalong with the \033[1mcurrent\033[0m directory. "
read -p "Do you want to update auto-cpufreq to the latest release? [y/n]: " ans
if [[ "$ans" == "y" ]]; then
header "Updating auto-cpufreq to the latest release\n"
tool_remove
echo -e "deleting the current directory\n"
script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
mkdir "$script_directory/../auto-cpufreq $latest_version" && cd $_
rm -rf $script_directory
echo -e "cloning to the latest release\n"
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq
separator
tool_install
else
separator
echo "Aborting..."
sleep 0.5
fi
fi
}

function ask_operation {
header "auto-cpufreq installer"
echo -e "Welcome to auto-cpufreq tool installer.
\nOptions:\n"
read -p \
"[I]nstall
[U]pdate
[R]emove
[Q]uit

Select a key: [i/r/q]: " answer
Select a key: [i/u/r/q]: " answer
}
# End of functions

Expand All @@ -280,6 +325,9 @@ else
"--install")
answer="i"
;;
"--update")
answer="u"
;;
"--remove")
answer="r"
;;
Expand All @@ -292,6 +340,8 @@ fi
case $answer in
I|i)
tool_install ;;
U|u)
tool_update ;;
R|r)
tool_remove ;;
Q|q)
Expand Down
Empty file modified auto-cpufreq.conf-example
100644 → 100755
Empty file.
Empty file modified auto_cpufreq/__init__.py
100644 → 100755
Empty file.
42 changes: 40 additions & 2 deletions auto_cpufreq/core.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from pathlib import Path
from shutil import which
from subprocess import getoutput, call, run, check_output, DEVNULL
import requests
import re

# execution timestamp used in countdown func
from datetime import datetime
Expand Down Expand Up @@ -159,7 +161,41 @@ def app_version():
except Exception as e:
print(repr(e))
pass

def verify_update():
# 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 = requests.get(latest_release_url).json()
latest_version = latest_release["tag_name"]

# Get the current version of auto-cpufreq
# Extract version number from the output string
output = check_output(['auto-cpufreq', '--version']).decode('utf-8')
version_line = next((re.search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None)
installed_version = "v" + version_line
#Check whether the same is installed or not
# Compare the latest version with the installed version and perform update if necessary
if latest_version == installed_version:
print("auto-cpufreq is up to date")
exit(0)
else:
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")

def new_update():
username = os.getlogin()
home_dir = "/home/" + username
os.chdir(home_dir)
current_working_directory = os.getcwd()
print("Cloning the latest release to the home directory: ")
print(os.getcwd())
run(["git", "clone", "https://github.com/AdnanHodzic/auto-cpufreq.git"])
os.chdir("auto-cpufreq")
print("package cloned to directory ", current_working_directory)
run(['./auto-cpufreq-installer'], input='i\n', encoding='utf-8')


# return formatted version for a better readability
def get_formatted_version():
literal_version = pkg_resources.require("auto-cpufreq")[0].version
Expand Down Expand Up @@ -413,7 +449,8 @@ def deploy_daemon_performance():

# output warning if gnome power profile is running
gnome_power_detect_install()
gnome_power_svc_disable_performance()
#"gnome_power_svc_disable_performance" is not defined
# gnome_power_svc_disable_performance()
cosmos1721 marked this conversation as resolved.
Show resolved Hide resolved

# output warning if TLP service is detected
tlp_service_detect()
Expand Down Expand Up @@ -1255,3 +1292,4 @@ def not_running_daemon_check():
elif os.getenv("PKG_MARKER") == "SNAP" and dcheck == "disabled":
daemon_not_running_msg()
exit(1)

Empty file modified auto_cpufreq/power_helper.py
100644 → 100755
Empty file.
Empty file modified auto_cpufreq/tlp_stat_parser.py
100644 → 100755
Empty file.
Loading