Improve compatible for Arch based distributions (#691)

* Add dinit

* Add dinit

* Change arch based informations

* More compatible for Arch based distributions

* More compatible for Arch based distributions

* Clean code

* Clean code
This commit is contained in:
Angel 2024-05-09 23:34:07 +02:00 committed by GitHub
parent b8f864e87e
commit eb0ba8aa7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 204 additions and 237 deletions

194
README.md
View File

@ -24,46 +24,46 @@ Example of `auto-cpufreq --stats` CLI output
## Looking for developers and co-maintainers
* If you would like to discuss anything regarding auto-cpufreq or its development, please join the [auto-cpufreq Discord server!](https://discord.gg/Sjauxtj6kH)
* auto-cpufreq is looking for [co-maintainers & open source developers to help shape the future of the project!](https://github.com/AdnanHodzic/auto-cpufreq/discussions/312)
- If you would like to discuss anything regarding auto-cpufreq or its development, please join the [auto-cpufreq Discord server!](https://discord.gg/Sjauxtj6kH)
- auto-cpufreq is looking for [co-maintainers & open source developers to help shape the future of the project!](https://github.com/AdnanHodzic/auto-cpufreq/discussions/312)
## Index
* [Why do I need auto-cpufreq?](#why-do-i-need-auto-cpufreq)
* [Supported architectures and devices](#supported-architectures-and-devices)
* [Features](#features)
* [Installing auto-cpufreq](#installing-auto-cpufreq)
* [auto-cpufreq-installer](#auto-cpufreq-installer)
* [Snap Store](#snap-store)
* [AUR package (Arch/Manjaro Linux)](#aur-package-archmanjaro-linux)
* [NixOS](#nixos)
* [For developers](#installation-development-mode-only)
* [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)
* [2: `--force` governor override](#2---force-governor-override)
* [3: auto-cpufreq config file](#3-auto-cpufreq-config-file)
* [Example config file contents](#example-config-file-contents)
* [How to run auto-cpufreq](#how-to-run-auto-cpufreq)
* [auto-cpufreq modes and options](#auto-cpufreq-modes-and-options)
* [monitor](#monitor)
* [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)
* [Battery charging thresholds](#battery-charging-thresholds)
* [Supported Devices](#supported-devices)
* [Battery config](#battery-config)
* [Troubleshooting](#troubleshooting)
* [AUR](#aur)
* [Discussion](#discussion)
* [Donate](#donate)
* [Financial donation](#financial-donation)
* [Paypal](#paypal)
* [BitCoin](#bitcoin)
* [Code contribution](#code-contribution)
- [Why do I need auto-cpufreq?](#why-do-i-need-auto-cpufreq)
- [Supported architectures and devices](#supported-architectures-and-devices)
- [Features](#features)
- [Installing auto-cpufreq](#installing-auto-cpufreq)
- [auto-cpufreq-installer](#auto-cpufreq-installer)
- [Snap Store](#snap-store)
- [AUR package (Arch based distributions)](#aur-package-arch-based-distributions)
- [NixOS](#nixos)
- [For developers](#installation-development-mode-only)
- [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)
- [2: `--force` governor override](#2---force-governor-override)
- [3: auto-cpufreq config file](#3-auto-cpufreq-config-file)
- [Example config file contents](#example-config-file-contents)
- [How to run auto-cpufreq](#how-to-run-auto-cpufreq)
- [auto-cpufreq modes and options](#auto-cpufreq-modes-and-options)
- [monitor](#monitor)
- [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)
- [Battery charging thresholds](#battery-charging-thresholds)
- [Supported Devices](#supported-devices)
- [Battery config](#battery-config)
- [Troubleshooting](#troubleshooting)
- [AUR](#aur)
- [Discussion](#discussion)
- [Donate](#donate)
- [Financial donation](#financial-donation)
- [Paypal](#paypal)
- [BitCoin](#bitcoin)
- [Code contribution](#code-contribution)
## Why do I need auto-cpufreq?
@ -85,20 +85,20 @@ Only devices with an Intel, AMD, or ARM CPU are supported. This tool was develop
## Features
* Monitoring
* Basic system information
* CPU frequency (system total & per core)
* CPU usage (system total & per core)
* CPU temperature (total average & per core)
* Battery state
* System load
* CPU frequency scaling, governor, and [turbo boost](https://en.wikipedia.org/wiki/Intel_Turbo_Boost) management based on
* Battery state
* CPU usage (total & per core)
* CPU temperature in combination with CPU utilization/load (to prevent overheating)
* System load
* Automatic CPU & power optimization (temporary and persistent)
* Settings battery charging thresholds (limited support)
- Monitoring
- Basic system information
- CPU frequency (system total & per core)
- CPU usage (system total & per core)
- CPU temperature (total average & per core)
- Battery state
- System load
- CPU frequency scaling, governor, and [turbo boost](https://en.wikipedia.org/wiki/Intel_Turbo_Boost) management based on
- Battery state
- CPU usage (total & per core)
- CPU temperature in combination with CPU utilization/load (to prevent overheating)
- System load
- Automatic CPU & power optimization (temporary and persistent)
- Settings battery charging thresholds (limited support)
## Installing auto-cpufreq
@ -124,11 +124,11 @@ sudo snap install auto-cpufreq
```
**Please note:**
* Make sure [snapd](https://snapcraft.io/docs/installing-snapd) is installed and `snap version` is >= 2.44 for `auto-cpufreq` to fully work due to [recent snapd changes](https://github.com/snapcore/snapd/pull/8127).
- Make sure [snapd](https://snapcraft.io/docs/installing-snapd) is installed and `snap 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 the 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 the 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.
### AUR package (Arch/Manjaro Linux)
### AUR package (Arch based distributions)
[![AUR package](https://repology.org/badge/version-for-repo/aur/auto-cpufreq.svg)](https://aur.archlinux.org/packages/auto-cpufreq)
@ -136,15 +136,15 @@ The AUR [Release Package](https://aur.archlinux.org/packages/auto-cpufreq) is cu
**Notices**
* The [Git Package](https://aur.archlinux.org/packages/auto-cpufreq-git) is seperately maintained and was last updated on version 1.9.6.
* The build process links to `/usr/share/` instead of `/usr/local/share/`
* The daemon installer provided does not work, instead start the daemon with
- The [Git Package](https://aur.archlinux.org/packages/auto-cpufreq-git) is seperately maintained and was last updated on version 1.9.6.
- The build process links to `/usr/share/` instead of `/usr/local/share/`
- The daemon installer provided does not work, instead start the daemon with
```
# systemctl enable --now auto-cpufreq
```
* The GNOME Power Profiles daemon is [automatically disabled by auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq#1-power_helperpy-script-snap-package-install-only) due to it's conflict with auto-cpufreq.service. However, this doesn't happen with AUR installs, which can lead to problems (e.g., [#463](https://github.com/AdnanHodzic/auto-cpufreq/issues/463)) if not masked manually.
* Open a terminal and run `sudo systemctl mask power-profiles-daemon.service` (then `enable` and `start` the auto-cpufreq.service if you haven't already).
- The GNOME Power Profiles daemon is [automatically disabled by auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq#1-power_helperpy-script-snap-package-install-only) due to it's conflict with auto-cpufreq.service. However, this doesn't happen with AUR installs, which can lead to problems (e.g., [#463](https://github.com/AdnanHodzic/auto-cpufreq/issues/463)) if not masked manually.
- Open a terminal and run `sudo systemctl mask power-profiles-daemon.service` (then `enable` and `start` the auto-cpufreq.service if you haven't already).
### NixOS
@ -352,47 +352,47 @@ turbo = auto
## How to run auto-cpufreq
auto-cpufreq should be run with with one of the following options:
* [monitor](#monitor)
- Monitor and see suggestions for CPU optimizations
- [monitor](#monitor)
- Monitor and see suggestions for CPU optimizations
* [live](#live)
- Monitor and automatically make (temporary) CPU optimizations
- [live](#live)
- Monitor and automatically make (temporary) CPU optimizations
* [install](#install---auto-cpufreq-daemon) / [remove](#remove---auto-cpufreq-daemon)
- Install/remove daemon for (permanent) automatic CPU optimizations
- [install](#install---auto-cpufreq-daemon) / [remove](#remove---auto-cpufreq-daemon)
- Install/remove daemon for (permanent) automatic CPU optimizations
* [install (GUI)](#install---auto-cpufreq-daemon)
- Install daemon via GUI for (permanent) automatic CPU optimizations
- [install (GUI)](#install---auto-cpufreq-daemon)
- Install daemon via GUI for (permanent) automatic CPU optimizations
* [update](#update---auto-cpufreq-update)
- Update auto-cpufreq to the latest release
- [update](#update---auto-cpufreq-update)
- Update auto-cpufreq to the latest release
* [install_performance](#1-power_helperpy-script)
- Install daemon in "performance" mode
- [install_performance](#1-power_helperpy-script)
- Install daemon in "performance" mode
* [stats](#stats)
- View live stats of CPU optimizations made by daemon
- [stats](#stats)
- View live stats of CPU optimizations made by daemon
* [force=TEXT](#overriding-governor)
- Force use of either the "powersave" or "performance" governor, or set to "reset" to go back to normal mode
- [force=TEXT](#overriding-governor)
- Force use of either the "powersave" or "performance" governor, or set to "reset" to go back to normal mode
* config=TEXT
- Use config file at designated path
- config=TEXT
- Use config file at designated path
* debug
- Show debug info (include when submitting bugs)
- debug
- Show debug info (include when submitting bugs)
* version
- Show currently installed version
- version
- Show currently installed version
* [donate](#financial-donation)
- To support the project
- [donate](#financial-donation)
- To support the project
* help
- Shows all of the above options
- help
- Shows all of the above options
* completions=TEXT
- To support shell completions (current options are "bash", "zsh", or "fish")
- completions=TEXT
- To support shell completions (current options are "bash", "zsh", or "fish")
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.
@ -489,8 +489,8 @@ As of [v2.2.0](https://github.com/AdnanHodzic/auto-cpufreq/releases/tag/v2.2.0),
### Supported devices
* **Lenovo ThinkPad** (thinkpad_acpi)*
* **Lenovo IdeaPad** (ideapad_acpi)*
- **Lenovo ThinkPad** (thinkpad_acpi)*
- **Lenovo IdeaPad** (ideapad_acpi)*
***Please note, your laptop must have an installed ACPI kernel driver specific to the manufacturer.** To check if you have the correct module installed and loaded run `lsmod [module]`
@ -516,10 +516,10 @@ add `ideapad_laptop_conservation_mode = true` to your `auto-cpufreq.conf` file
## Troubleshooting
**Q:** If after installing auto-cpufreq you're (still) experiencing:
* high CPU temperatures
* CPU not scaling to minimum/maximum frequencies
* suboptimal CPU performance
* turbo mode not available
- high CPU temperatures
- CPU not scaling to minimum/maximum frequencies
- suboptimal CPU performance
- turbo mode not available
**A:** If you're using the `intel_pstate/amd-pstate` CPU management driver, consider changing it to `acpi-cpufreq`.
@ -580,18 +580,18 @@ Once you have made the necessary changes to the `cmdline` file, you can update i
### AUR
* If the AUR installer does not work for your system, fallback to `auto-cpufreq-installer` and open an issue.
- If the AUR installer does not work for your system, fallback to `auto-cpufreq-installer` and open an issue.
## Discussion:
* Blogpost: [auto-cpufreq - Automatic CPU speed & power optimizer for Linux](http://foolcontrol.org/?p=3124)
- Blogpost: [auto-cpufreq - Automatic CPU speed & power optimizer for Linux](http://foolcontrol.org/?p=3124)
## Donate
Showing your support and appreciation for the auto-cpufreq project can be done in two ways:
* Financial donation
* Code contribution
- Financial donation
- Code contribution
### Financial donation

View File

@ -3,9 +3,7 @@
# auto-cpufreq-installer:
# auto-cpufreq source code based installer
SCRIPT_PATH=$(readlink -f "$0")
SCRIPT_DIR=$(dirname "${SCRIPT_PATH}")
cd "${SCRIPT_DIR}"
cd "$(dirname "$(readlink -f "$0")")" || exit 1
# check if lsb_release exists on the system before using it
if command -v lsb_release > /dev/null
@ -47,16 +45,6 @@ function header {
return
}
# python packages install
function setup_venv {
venv_dir=/opt/auto-cpufreq/venv
mkdir -p "${venv_dir}"
python3 -m venv "${venv_dir}"
source "${venv_dir}/bin/activate"
python3 -m pip install --upgrade pip wheel
}
# tool install
function install {
git config --global --add safe.directory $(pwd)
@ -78,133 +66,119 @@ function install {
}
# First argument is the distro
function detected_distro() {
function detected_distro {
echo -e "\nDetected $1 distribution"
separator
echo -e "\nSetting up Python environment\n"
}
# merged functions pip - install - complete_msg, since it repeats
function completed () {
echo -e "\nInstalling necessary Python packages\n"
setup_venv
separator
echo -e "\ninstalling auto-cpufreq tool\n"
install
}
function complete_msg() {
separator
cat <<- _EOF_
auto-cpufreq tool successfully installed.
For list of options, run:
auto-cpufreq --help"
_EOF_
separator
}
function manual_install {
cat <<- _EOF_
echo -e "
Didn't detect Debian or RedHat or Arch based distro.
Didn't detect Debian or RedHat based distro.
To complete installation, you need to:
Install: python3, pip3, python3-setuptools, gobject-introspection, cairo (or cairo-devel), gcc, and gtk3
To complete installation, you need to:
Install: python3, pip3, python3-setuptools, gobject-introspection, cairo (or cairo-devel), gcc, and gtk3
Install necessary Python packages:
pip3 install psutil click distro power requests PyGObject
Run following sequence of lines:
Install necessary Python packages:
pip3 install psutil click distro power requests PyGObject
Run following sequence of lines:
-----
-----
pip3 install .
mkdir -p /usr/local/share/auto-cpufreq/
cp -r scripts/ /usr/local/share/auto-cpufreq/
pip3 install .
mkdir -p /usr/local/share/auto-cpufreq/
cp -r scripts/ /usr/local/share/auto-cpufreq/
-----
-----
After which tool is installed, for full list of options run:
After which tool is installed, for full list of options run:
auto-cpufreq
_EOF_
auto-cpufreq"
separator
cat <<- _EOF_
echo -e "
Consider creating a feature request to add support for your distro:
https://github.com/AdnanHodzic/auto-cpufreq/issues/new
Consider creating a feature request to add support for your distro:
https://github.com/AdnanHodzic/auto-cpufreq/issues/new
Make sure to include following information:
Make sure to include following information:
Distribution: $distro
Release: $release
Codename: $codename
_EOF_
Distribution: $distro
Release: $release
Codename: $codename"
separator
}
function tool_install {
separator
if [ -f /etc/debian_version ]; then
detected_distro "Debian based"
apt install python3-dev python3-pip python3-venv python3-setuptools dmidecode libgirepository1.0-dev libcairo2-dev libgtk-3-dev gcc -y
completed
complete_msg
elif [ -f /etc/redhat-release ]; then
detected_distro "RedHat based"
if [ -f /etc/centos-release ]; then
yum install platform-python-devel dmidecode gcc cairo-devel gobject-introspection-devel cairo-gobject-devel gtk3-devel
else
yum install python-devel dmidecode gcc cairo-devel gobject-introspection-devel cairo-gobject-devel gtk3-devel
fi
completed
complete_msg
elif [ -f /etc/solus-release ]; then
detected_distro "Solus"
eopkg install pip python3 python3-devel dmidecode gobject-introspection-devel libcairo-devel gcc libgtk-3
eopkg install -c system.devel
completed
complete_msg
elif [ -f /etc/os-release ];then
eval "$(cat /etc/os-release)"
separator
case $ID in
opensuse-leap)
detected_distro "OpenSUSE"
zypper install -y python3 python3-pip python3-setuptools python3-devel gcc dmidecode gobject-introspection-devel python3-cairo-devel gtk3 gtk3-devel
completed
;;
opensuse-tumbleweed)
detected_distro "OpenSUSE"
echo -e "\nDetected an OpenSUSE distribution\n\nSetting up Python environment\n"
zypper install -y python38 python3-pip python3-setuptools python3-devel gcc dmidecode gobject-introspection-devel python3-cairo-devel gtk3 gtk3-devel
completed
;;
arch|manjaro|endeavouros|garuda|artix)
detected_distro "Arch Linux based"
pacman -S --noconfirm --needed python python-pip python-setuptools base-devel dmidecode gobject-introspection gtk3 gcc
completed
;;
void)
detected_distro "Void Linux"
xbps-install -Sy python3 python3-pip python3-devel python3-setuptools base-devel dmidecode cairo-devel gobject-introspection gcc gtk+3
completed
;;
nixos)
echo -e "NixOS detected\n"
echo -e "This installer is not supported on NixOS.\nPlease refer to the install instructions for NixOS at https://github.com/AdnanHodzic/auto-cpufreq#nixos"
separator
if [ -f /etc/debian_version ]; then
detected_distro "Debian based"
apt install python3-dev python3-pip python3-venv python3-setuptools dmidecode libgirepository1.0-dev libcairo2-dev libgtk-3-dev gcc -y
elif [ -f /etc/redhat-release ]; then
detected_distro "RedHat based"
if [ -f /etc/centos-release ]; then yum install platform-python-devel
else yum install python-devel
fi
yum install dmidecode gcc cairo-devel gobject-introspection-devel cairo-gobject-devel gtk3-devel
elif [ -f /etc/solus-release ]; then
detected_distro "Solus"
eopkg install pip python3 python3-devel dmidecode gobject-introspection-devel libcairo-devel gcc libgtk-3
eopkg install -c system.devel
elif [ -f /etc/arch-release ]; then
detected_distro "Arch Linux based"
pacman -S --noconfirm --needed python python-pip python-setuptools base-devel dmidecode gobject-introspection gtk3 gcc
elif [ -f /etc/os-release ];then
eval "$(cat /etc/os-release)"
separator
case $ID in
opensuse-leap)
detected_distro "OpenSUSE"
zypper install -y python3 python3-pip python3-setuptools python3-devel gcc dmidecode gobject-introspection-devel python3-cairo-devel gtk3 gtk3-devel
;;
opensuse-tumbleweed)
detected_distro "OpenSUSE"
zypper install -y python38 python3-pip python3-setuptools python3-devel gcc dmidecode gobject-introspection-devel python3-cairo-devel gtk3 gtk3-devel
;;
void)
detected_distro "Void Linux"
xbps-install -Sy python3 python3-pip python3-devel python3-setuptools base-devel dmidecode cairo-devel gobject-introspection gcc gtk+3
;;
nixos)
echo -e "NixOS detected\n"
echo -e "This installer is not supported on NixOS.\nPlease refer to the install instructions for NixOS at https://github.com/AdnanHodzic/auto-cpufreq#nixos"
exit 1
;;
*) manual_install;;
esac
else # In case /etc/os-release doesn't exist
manual_install
exit 1
;;
*) #Any other distro
manual_install
completed
;;
esac
complete_msg
else # In case /etc/os-release doesn't exist
manual_install
fi
fi
echo -e "\nInstalling necessary Python packages\n"
venv_dir=/opt/auto-cpufreq/venv
mkdir -p "${venv_dir}"
python3 -m venv "${venv_dir}"
source "${venv_dir}/bin/activate"
python3 -m pip install --upgrade pip wheel
separator
echo -e "\ninstalling auto-cpufreq tool\n"
install
separator
echo -e "
auto-cpufreq tool successfully installed.
For list of options, run:
auto-cpufreq --help"
separator
}
function tool_remove {
@ -293,33 +267,26 @@ Select a key: [i/r/q]: " answer
root_check
if [[ -z "${1}" ]]; then
ask_operation
if [[ -z "${1}" ]]; then ask_operation
else
case "${1}" in
"--install")
answer="i"
;;
"--remove")
answer="r"
;;
*)
answer="n"
;;
"--install") answer="i";;
"--remove") answer="r";;
*) answer="n";;
esac
fi
case $answer in
I|i)
tool_install ;;
R|r)
tool_remove ;;
I|i) tool_install;;
R|r) tool_remove;;
Q|q)
separator
echo ""
exit 0 ;;
separator
echo ""
exit 0
;;
*)
separator
echo -e "\nUnknown key, aborting ...\n"
exit 1 ;;
separator
echo -e "\nUnknown key, aborting ...\n"
exit 1
;;
esac