From 5d26803204bbd110185381f45277245d70ee016b Mon Sep 17 00:00:00 2001 From: Shrinivas Kumbhar <44837339+librewish@users.noreply.github.com> Date: Wed, 3 Feb 2021 13:48:03 +0530 Subject: [PATCH] use dmidecode and dependancies update (#163) --- auto-cpufreq-installer | 16 ++++++++-------- auto_cpufreq/core.py | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/auto-cpufreq-installer b/auto-cpufreq-installer index eaf27ef..7160276 100755 --- a/auto-cpufreq-installer +++ b/auto-cpufreq-installer @@ -52,7 +52,7 @@ then echo -e "\nDetected Debian based distribution" separator echo -e "\nSetting up Python environment\n" - apt install python3-dev python3-pip python3-setuptools -y + apt install python3-dev python3-pip python3-setuptools dmidecode -y separator echo -e "\nInstalling necessary Python packages\n" pip_pkg_install @@ -71,9 +71,9 @@ then # CentOS exception if [ -f /etc/centos-release ]; then - yum install platform-python-devel + yum install platform-python-devel dmidecode else - yum install python-devel + yum install python-devel dmidecode fi echo -e "\nInstalling necessary Python packages\n" pip_pkg_install @@ -89,7 +89,7 @@ then separator echo -e "\nDetected Solus distribution\n" echo -e "\nSetting up Python environment\n" - eopkg install pip python3 python3-devel + eopkg install pip python3 python3-devel dmidecode eopkg install -c system.devel echo -e "\nInstalling necessary Python packages\n" pip_pkg_install @@ -108,9 +108,9 @@ then echo -e "\nSetting up Python environment\n" if [[ $ID == "opensuse-leap" ]]; then - zypper install -y python3 python3-pip python3-setuptools python3-devel gcc + zypper install -y python3 python3-pip python3-setuptools python3-devel gcc dmidecode else - zypper install -y python38 python3-pip python3-setuptools python3-devel gcc + zypper install -y python38 python3-pip python3-setuptools python3-devel gcc dmidecode fi echo -e "\nInstalling necessary Python packages\n" pip_pkg_install @@ -121,12 +121,12 @@ then complete_msg separator # Manjaro/Arch -elif [ -f /etc/os-release ] && eval "$(cat /etc/os-release)" && [[ $ID == "manjaro" || $ID == "arch" ]]; +elif [ -f /etc/os-release ] && eval "$(cat /etc/os-release)" && [[ $ID == "manjaro" || $ID == "arch" || $ID == "garuda" ]]; then separator echo -e "\nDetected an Arch Linux based distribution\n" echo -e "\nSetting up Python environment\n" - pacman -S --noconfirm python python-pip python-setuptools gcc + pacman -S --noconfirm python python-pip python-setuptools gcc dmidecode echo -e "\nInstalling necessary Python packages\n" pip_pkg_install separator diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 90ff218..bd5846e 100644 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -117,9 +117,9 @@ def charging(): """ power_dir = "/sys/class/power_supply/" - computer_type = getoutput('hostnamectl status | grep Chassis | cut -f2 -d \":\" | tr -d \' \'') + computer_type = getoutput('dmidecode --string chassis-type') - if computer_type == "laptop": + if computer_type == "Notebook": # AC adapter states: 0, 1, unknown ac_info = getoutput(f"grep . {power_dir}A*/online").splitlines() # if there's one ac-adapter on-line, ac_state is True @@ -341,7 +341,7 @@ def display_load(): def set_powersave(): print(f"Setting to use: \"{get_avail_powersave()}\" governor") run(f"cpufreqctl.auto-cpufreq --governor --set={get_avail_powersave()}", shell=True) - if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists(): + if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() == False: run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True) print("Setting to use: \"balance_power\" EPP")