Giter Site home page Giter Site logo

adnanhodzic / auto-cpufreq Goto Github PK

View Code? Open in Web Editor NEW
5.0K 45.0 246.0 659 KB

Automatic CPU speed & power optimizer for Linux

Home Page: https://foolcontrol.org/?p=4603

License: GNU Lesser General Public License v3.0

Python 76.19% Shell 20.13% CSS 0.10% Nix 3.58%
cpu speed power frequency turbo boost governor linux automatic tool

auto-cpufreq's Introduction

auto-cpufreq

Linux Build Nix Flake

Automatic CPU speed & power optimizer for Linux. Actively monitors laptop battery state, CPU usage, CPU temperature, and system load, ultimately allowing you to improve battery life without making any compromises.

For tl;dr folks:

Youtube: auto-cpufreq v2.0 release & demo of all available features and options

Youtube: auto-cpufreq - tool demo

Example of auto-cpufreq GUI (available >= v2.0)

Example of auto-cpufreq desktop entry (icon)

Example of auto-cpufreq --stats CLI output

Example of auto-cpufreq desktop entry (icon)

Looking for developers and co-maintainers

Index

Why do I need auto-cpufreq?

One of the problems with Linux today on laptops is that the CPU will run in an unoptimized manner which will negatively impact battery life. For example, the CPU may run using the "performance" governor with turbo boost enabled regardless of whether it's plugged into a power outlet or not.

These issues can be mitigated by using tools like indicator-cpufreq or cpufreq, but those still require manual action from your side which can be daunting and cumbersome.

Tools like TLP (which I used for numerous years) can help extend battery life, but may also create their own set of problems, such as losing turbo boost.

Given all of the above, I needed a simple tool that would automatically make CPU frequency-related changes and save battery life, but let the Linux kernel do most of the heavy lifting. That's how auto-cpufreq was born.

Please note: auto-cpufreq aims to replace TLP in terms of functionality, so after you install auto-cpufreq it's recommended to remove TLP. Using both for the same functionality (i.e., to set CPU frequencies) will lead to unwanted results like overheating. Hence, only use both tools in tandem if you know what you're doing.

One tool/daemon that does not conflict with auto-cpufreq in any way, and is even recommended to have running alongside, is thermald.

Supported architectures and devices

Only devices with an Intel, AMD, or ARM CPU are supported. This tool was developed to improve performance and battery life on laptops, but running it on desktops/servers (to lower power consumption) should also be possible.

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 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

auto-cpufreq-installer

As auto-cpufreq relies on git based versioning, users are advised to install auto-cpufreq using git clone method only. Downloading source code as a zip/from release will emit build error like these.

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

Snap Store

Please note: while all auto-cpufreq >= v2.0 CLI functionality will work as intended, the GUI won't be available on Snap package installs due to Snap package confinement limitations. Hence, please consider installing auto-cpufreq using auto-cpufreq-installer.

auto-cpufreq is available on the Snap Store or via CLI:

sudo snap install auto-cpufreq

Please note:

AUR package (Arch/Manjaro Linux)

The AUR Release Package was last updated on version 2.2.0 and is currently being maintained by MusicalArtist12, liljaylj, and parmjotsinghrobot.

Notices

  • The Git Package 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 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) 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

Flakes

This repo contains a flake that exposes a NixOS Module that manages and offers options for auto-cpufreq. To use it, add the flake as an input to your flake.nix file and enable the module:

# flake.nix

{

    inputs = {
        # ---Snip---
        auto-cpufreq = {
            url = "github:AdnanHodzic/auto-cpufreq";
            inputs.nixpkgs.follows = "nixpkgs";
        };
        # ---Snip---
    }

    outputs = {nixpkgs, auto-cpufreq, ...} @ inputs: {
        nixosConfigurations.HOSTNAME = nixpkgs.lib.nixosSystem {
            specialArgs = { inherit inputs; };
            modules = [
                ./configuration.nix
                auto-cpufreq.nixosModules.default
            ];
        };
    } 
}

Then you can enable the program in your configuration.nix file:

# configuration.nix

{inputs, pkgs, ...}: {
    # ---Snip---
    programs.auto-cpufreq.enable = true;
    # optionally, you can configure your auto-cpufreq settings, if you have any
    programs.auto-cpufreq.settings = {
    charger = {
      governor = "performance";
      turbo = "auto";
    };

    battery = {
      governor = "powersave";
      turbo = "auto";
    };
  };
    # ---Snip---
}
Nixpkgs

There is a nixpkg available, but it is more prone to being outdated, whereas the flake pulls from the latest commit. You can install it in your configuration.nix and enable the system service:

# configuration.nix

# ---Snip---
environment.systemPackages = with pkgs; [
    auto-cpufreq
];

services.auto-cpufreq.enable = true;
# ---Snip---

Installation (development mode only)

  • If you have poetry installed:

    git clone https://github.com/AdnanHodzic/auto-cpufreq.git
    cd auto-cpufreq
    poetry install
    poetry run auto-cpufreq --help
  • Alternatively, we can use an editable pip install for development purposes:

    git clone https://github.com/AdnanHodzic/auto-cpufreq.git
    cd auto-cpufreq
    # set up virtual environment (details removed for brevity)
    pip3 install -e .
    auto-cpufreq
  • Regularly run poetry update if you get any inconsistent lock file issues.

Post-installation

After installation, auto-cpufreq is available as a binary. Refer to auto-cpufreq modes and options for detailed information on how to run and configure auto-cpufreq.

Configuring auto-cpufreq

auto-cpufreq makes all decisions automatically based on various factors such as CPU usage, temperature, and system load. However, it's possible to perform additional configurations:

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

When installing auto-cpufreq via auto-cpufreq-installer, if it detects the GNOME Power Profiles service is running, it will automatically disable it. Otherwise, that daemon will cause conflicts and various other performance issues.

However, when auto-cpufreq is installed as a Snap package it's running as part of a container with limited permissions, hence it's highly recommended to disable the GNOME Power Profiles daemon using the power_helper.py script.

Please Note:
The power_helper.py script is located within the auto-cpufreq repo at auto_cpufreq/power_helper.py. In order to access it, first clone the repository:

git clone https://github.com/AdnanHodzic/auto-cpufreq

Navigate to the directory where power_helper.py resides:

cd auto-cpufreq/auto_cpufreq

Make sure to have psutil Python library installed before next step:

sudo python3 -m pip install psutil

Then disable the GNOME Power Profiles daemon:

sudo python3 power_helper.py --gnome_power_disable

2: --force governor override

By default, auto-cpufreq uses balanced mode which works best for many systems and situations.

However, you can override this behaviour by switching to performance or powersave mode manually. The performance mode results in higher default frequencies, but also higher energy use (battery consumption) and should only be used if maximum performance is needed. The powersave mode does the opposite and extends battery life to its maximum.

See --force flag for more info.

3: auto-cpufreq config file

You can configure separate profiles for the battery and power supply. These profiles will let you pick which governor to use, as well as how and when turbo boost is enabled. The possible values for turbo boost behavior are always, auto, and never. The default behavior is auto, which only activates turbo during high load.

By default, auto-cpufreq does not use the config file! If you wish to use it, the location where it needs to be placed to be read automatically is: /etc/auto-cpufreq.conf

Example config file contents

# settings for when connected to a power source
[charger]
# see available governors by running: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
# preferred governor
governor = performance

# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = performance

# minimum cpu frequency (in kHz)
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
# to use this feature, uncomment the following line and set the value accordingly
# scaling_min_freq = 800000

# maximum cpu frequency (in kHz)
# example: for 1GHz = 1000 MHz = 1000000 kHz -> scaling_max_freq = 1000000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
# to use this feature, uncomment the following line and set the value accordingly
# scaling_max_freq = 1000000

# turbo boost setting. possible values: always, auto, never
turbo = auto

# settings for when using battery power
[battery]
# see available governors by running: cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
# preferred governor
governor = powersave

# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = power

# minimum cpu frequency (in kHz)
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
# to use this feature, uncomment the following line and set the value accordingly
# scaling_min_freq = 800000

# maximum cpu frequency (in kHz)
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
# example: for 1GHz = 1000 MHz = 1000000 kHz -> scaling_max_freq = 1000000
# to use this feature, uncomment the following line and set the value accordingly
# scaling_max_freq = 1000000

# turbo boost setting (always, auto, or never)
turbo = auto

# battery charging threshold
# reference: https://github.com/AdnanHodzic/auto-cpufreq/#battery-charging-thresholds
#enable_thresholds = true
#start_threshold = 20
#stop_threshold = 80

How to run auto-cpufreq

auto-cpufreq should be run with with one of the following options:

  • monitor

    • Monitor and see suggestions for CPU optimizations
  • live

    • Monitor and automatically make (temporary) CPU optimizations
  • install / remove

    • Install/remove daemon for (permanent) automatic CPU optimizations
  • install (GUI)

    • Install daemon via GUI for (permanent) automatic CPU optimizations
  • update

    • Update auto-cpufreq to the latest release
  • install_performance

    • Install daemon in "performance" mode
  • stats

    • View live stats of CPU optimizations made by daemon
  • force=TEXT

    • 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
  • debug

    • Show debug info (include when submitting bugs)
  • version

    • Show currently installed version
  • donate

    • To support the project
  • help

    • Shows all of the above options
  • 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 for more details.

auto-cpufreq modes and options

Monitor

sudo auto-cpufreq --monitor

No changes are made to the system. This is solely to demonstrate what auto-cpufreq could do for your system.

Live

sudo auto-cpufreq --live

Necessary changes are temporarily made to the system over time, but this process and its changes are lost at system reboot. This mode is provided to evaluate how the system would behave with auto-cpufreq permanently running on the system.

Overriding governor

sudo auto-cpufreq --force=governor

Force use of either the "powersave" or "performance" governor, or set to "reset" to go back to normal mode. Please note that any set override will persist even after reboot.

Install - auto-cpufreq daemon

Necessary changes are made to the system over time and this process will continue across reboots. The daemon is deployed and started as a systemd service. Changes are made automatically and live stats are generated for monitoring purposes.

Install the daemon using CLI (after installing auto-cpufreq):

Installing the auto-cpufreq daemon using CLI is as simple as running the following command:

sudo auto-cpufreq --install

After the daemon is installed, auto-cpufreq is available as a binary and runs in the background. Its stats can be viewed by running: auto-cpufreq --stats

Please note: if the daemon is installed within a desktop environment, then its stats and options can be accessed via CLI or GUI. See "Install the daemon using GUI" below for more details.

Install the daemon using GUI

Starting with >= v2.0 after installing auto-cpufreq, an auto-cpufreq desktop entry (icon) is available, i.e.:

Example of auto-cpufreq desktop entry (icon)

After selecting it to open the GUI, the auto-cpufreq daemon can be installed by clicking the "Install" button:

The auto-cpufreq GUI's 'Install' button

After that, the full auto-cpufreq GUI is available:

The full auto-cpufreq GUI

Please note: after the daemon is installed (by any method), its stats and options are accessible via both CLI and GUI.

auto-cpufreq daemon service

Installing the auto-cpufreq daemon also enables the associated service (equivalent to systemctl enable auto-cpufreq), causing it to start on boot, and immediately starts it (equivalent to systemctl start auto-cpufreq).

Since the daemon is running as a systemd service, its status can be seen by running:

systemctl status auto-cpufreq

If installed via Snap package, daemon status can be viewed as follows:

systemctl status snap.auto-cpufreq.service.service

Update - auto-cpufreq update

Update functionality works by cloning the auto-cpufreq repo, installing it via auto-cpufreq-installer, and performing a fresh auto-cpufreq daemon install to provide the latest version's changes.

Update auto-cpufreq by running: sudo auto-cpufreq --update. By default, the latest revision is cloned to /opt/auto-cpufreq/source, thus maintaining existing directory structure.

Update and clone to a custom directory by running: sudo auto-cpufreq --update=/path/to/directory

Remove - auto-cpufreq daemon

The auto-cpufreq daemon, its systemd service, and all its persistent changes can be removed by running:

sudo auto-cpufreq --remove

This does, in part, the equivalent of systemctl stop auto-cpufreq && systemctl disable auto-cpufreq, but the above command should be used instead of using systemctl.

Please note: after the daemon is removed, the auto-cpufreq GUI and desktop entry (icon) are also removed.

Stats

If the daemon has been installed, live stats of CPU/system load monitoring and optimization can be seen by running:

auto-cpufreq --stats

Battery charging thresholds

As of v2.2.0, battery charging thresholds can be set in the config file. This enforces your battery to start and stop charging at defined values

Supported devices

  • 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]

To request that your device be supported, please open an issue. In your issue, make us aware of the driver that works with your laptop

Battery config

Edit the config at /etc/auto-cpufreq.conf

Example config for battery (already part of example config file)

[battery]
enable_thresholds = true
start_threshold = 20
stop_threshold = 80

Lenovo_laptop conservation mode

this works only with lenovo_laptop kernel module compatable laptops.

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

A: If you're using the intel_pstate/amd-pstate CPU management driver, consider changing it to acpi-cpufreq.

This can be done by editing the GRUB_CMDLINE_LINUX_DEFAULT params in /etc/default/grub. For instance:

    sudo nano /etc/default/grub
    # make sure you have nano installed, or you can use your favorite text editor

For Intel users:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_pstate=disable"

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 GRUB by running sudo update-grub on Debian/Ubuntu, sudo grub-mkconfig -o /boot/grub/grub.cfg on Arch Linux, or one of the following on Fedora:

    sudo grub2-mkconfig -o /etc/grub2.cfg
    sudo grub2-mkconfig -o /etc/grub2-efi.cfg
    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
    # legacy boot method

For systemd-boot users:

    sudo nano /etc/kernel/cmdline
    # make sure you have nano installed, or you can use your favorite text editor

For Intel users:

quiet splash intel_pstate=disable

For AMD users:

quiet splash initcall_blacklist=amd_pstate_init amd_pstate.enable=0

Once you have made the necessary changes to the cmdline file, you can update it by running sudo reinstall-kernels.

AUR

  • If the AUR installer does not work for your system, fallback to auto-cpufreq-installer and open an issue.

Discussion:

Donate

Showing your support and appreciation for the auto-cpufreq project can be done in two ways:

  • Financial donation
  • Code contribution

Financial donation

If auto-cpufreq helped you out and you find it useful, show your appreciation by donating (any amount) to the project!

PayPal

paypal

BitCoin

bc1qlncmgdjyqy8pe4gad4k2s6xtyr8f2r3ehrnl87

bitcoin

Code contribution

Other ways of supporting the project consist of making a code or documentation contribution. If you have an idea for a new feature or you want to implement some of the existing feature requests or fix some of the bugs & issues, please make your changes and submit a pull request. I'll be glad to review it and, if your changes are accepted, you'll be credited on the releases page.

Please note: auto-cpufreq is looking for co-maintainers & open source developers to help shape the future of the project!

auto-cpufreq's People

Contributors

abvee avatar adnanhodzic avatar amitgolden avatar animeshz avatar ariasmn avatar aroundthfur avatar asperan avatar blackpill0w avatar bobslept avatar cosmos1721 avatar dependabot[bot] avatar emilyastranova avatar explosion-mental avatar haptein avatar hingen avatar isabelroses avatar marc0der avatar musicalartist12 avatar natri23 avatar purplewazard avatar red-eyed avatar rootcircle avatar rrodriguez81 avatar shadeyg56 avatar sunkenhero avatar validatedev avatar varaki avatar yochananmarqos avatar yustynn avatar zoitrok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auto-cpufreq's Issues

Doesn't report Architecture

Probably minor, but when running it doesn't report the architecture, i.e. it is empty:

                                                                                                                                                                                                              [30/30]
----------------------------- System information ------------------------------
               
Linux distro: Debian GNU/Linux 10 buster
Linux kernel: 4.19.0-6-amd64
Driver: intel_pstate
Architecture:  
Processor: Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Cores: 12
                                                                               
------------------------------ Current CPU states ------------------------------

The systemd log is being spammed by auto-cpufreq

I've started using the tool and loving it so far. Good work!

After installation, the auto-cpufreq service is continually outputting the full payload of the --log command to the system logs.

When tailing the logs with journalctl --follow, I see a continual stream of these log reports being dumped in the log every 5 seconds.

...
Aug 07 12:34:18 rocinante auto-cpufreq.service[561395]: ----------------------------- System information ------------------------------
Aug 07 12:34:18 rocinante auto-cpufreq.service[561395]: Linux distro: Manjaro Linux UNKNOWN version
Aug 07 12:34:18 rocinante auto-cpufreq.service[561395]: Linux kernel: 5.4.52-1-MANJARO
Aug 07 12:34:18 rocinante auto-cpufreq.service[561395]: Driver: intel_pstate
Aug 07 12:34:18 rocinante auto-cpufreq.service[561395]: Architecture: x86_64
Aug 07 12:34:18 rocinante auto-cpufreq.service[561395]: Processor: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
...

My system info:

               +
               #
              ###
             #####
             ######
            ; #####;            User: marco
           +##.#####            Hostname: rocinante
          +##########           Distro: Arch Linux
         #############;         Kernel: 5.4.52-1-MANJARO
        ###############+        Uptime: 10 days, 14:03
       #######   #######        Window Manager: i3
     .######;     ;###;`".      Desktop Environment:
    .#######;     ;#####.       Shell: /bin/zsh
    #########.   .########`     Terminal: screen-256color
   ######'           '######    Packages: 1588
  ;####                 ####;   CPU: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
  ##'                     '##   RAM: 6717 MB / 15766 MB
 #'                         `#  Disk: 469GB / 989GB

Installed with snap:

snap     2.45.2-1
snapd    2.45.2-1
series   16
manjaro  -
kernel   5.4.52-1-MANJARO

Should this perhaps rather be a one-line summary whenever the state of cpu scaling is changed by the tool?

I also further noticed the continued references to a /var/log/auto-cpufreq.log file in the service descriptor and elsewhere, but this file never seems to be created. I tried creating it myself, but it still doesn't get populated with the logs.

I realise that these are just teething issues that still need to be sorted. Keep up the great work!

KeyError: 'coretemp'

From another directory I got this (file does not exist):
cp: no se puede efectuar stat' sobre 'scripts/cpufreqctl.sh': No existe el fichero o el directorio`

But, executing when pwd is inside the directory auto-cpufreq, then the error mensaje is this:

python3 auto-cpufreq.py --monitor

----------------------------- System information ------------------------------

Linux distro: PCLinuxOS 2020 PCLinuxOS
Linux kernel: 5.4.8-pclos1
Driver: intel_pstate
Architecture: x86_64
Processor: Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
Cores: 4

------------------------------ Current CPU states ------------------------------

CPU max frequency: 
3200 MHz

CPU frequency for each core:

CPU0: 1898 MHz
CPU1: 1702 MHz
CPU2: 2149 MHz
CPU3: 1566 MHz

Temperature for each physical core:

Traceback (most recent call last):
  File "auto-cpufreq.py", line 437, in <module>
    cli()
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib64/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "auto-cpufreq.py", line 410, in cli
    sysinfo()
  File "auto-cpufreq.py", line 338, in sysinfo
    print("CPU" + str(core_num) + " temp: {:.0f}".format(core_temp['coretemp'][core_num].current) + "°C")
KeyError: 'coretemp'

[feature request] Make an editable config file

How about making a config file to specify the powersave vs performance and turbo-boost constants, which are currently hardcoded in the set_powersave and mon_powersave and related functions.

This could be a long term goal and would expose tweak-ability in a format similar to tlp.

[Feature] add more info into --debug

Since sensors are very different across the machines I think that it would be nice to add output of psutil.sensors_temperature() into get_sys_info() function
also, we need to know the version and the way user start it (snap or directly from the git)

in general, we should add:

  • sensors info
  • app version info
  • Is it snap or git?
  • If snap -> snap version output

maybe more

Single Core / Battery status / cp stat

Hey there,

I like your tool very much and gave it some testing. On Geekbench 5 I score on the Multi Core test about the same, as when I set my system manually to its maximum. Yet the Single Core test only yields 3/4 of the result. Turbo Boost stays off and the cpu never goes beyond its base frequency then.

Second thing: the log constantly reports that my battery is discharging, even when the ACPI is on-line. Therefore it says it always puts the governor to powersave. Maybe only a logging error since the Multi Core test was good in the benchmark.

Third thing: upon calling the log I get this error:
cp: der Aufruf von stat für '/usr/local/share/auto-cpufreq/scripts/cpufreqctl.sh' ist nicht möglich: Datei oder Verzeichnis nicht gefunden
cp: call of stat for '/usr....' is not possible: File or directory not found
Looks like something isnt copied the right way.

Here are my specs for reference:

image

Would be great, if you find the time to look into it. :)

Thx and greetings
~ent

/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference

Hi!
Got error when use
sudo auto-cpufreq --live

Setting to use "performance" governor
/usr/bin/cpufreqctl: row 267: /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference: Access denied
/usr/bin/cpufreqctl: row 267: /sys/devices/system/cpu/cpu1/cpufreq/energy_performance_preference: Access denied
/usr/bin/cpufreqctl: row 267: /sys/devices/system/cpu/cpu2/cpufreq/energy_performance_preference: Access denied
/usr/bin/cpufreqctl: row 267: /sys/devices/system/cpu/cpu3/cpufreq/energy_performance_preference: Access denied

I check that files and they doesn't exist....
Ubuntu 18.04.4

Error: Couldn't find any of the necessary scaling governors. AMD CPU possibly not supported?

I got this error while running the tool with a AMD Ryzen 7 PRO 3700U cpu.

If this error is indeed caused because the AMD cpu isn't supported, might I suggest updating the README to reflect this? If this isn't what's causing the error I'd have to look more into it and I'd gladly provide any needed information.

Output of sudo tlp-stat -p

--- TLP 1.2.2 --------------------------------------------

+++ Processor
CPU model      = AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = acpi-cpufreq
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = ondemand
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = ondemand performance schedutil 
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =  1400000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  2300000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies = 2300000 1700000 1400000 [kHz]

(Idem for the remaining seven cores)

/sys/devices/system/cpu/cpufreq/boost                  = 1

x86_energy_perf_policy: unsupported CPU.

/sys/module/workqueue/parameters/power_efficient       = N
/proc/sys/kernel/nmi_watchdog                          = 0

+++ Undervolting
PHC kernel not available.

Fails when core temperatures are not found

My APU does not report temps for each core so it fails.

Output of:

import psutil

print(psutil.sensors_temperatures())
{'nvme': [shwtemp(label='Composite', current=37.85, high=84.85, critical=84.85), shwtemp(label='Sensor 1', current=37.85, high=65261.85, critical=65261.85), shwtemp(label='Sensor 2', current=37.85, high=65261.85, critical=65261.85)], 'k10temp': [shwtemp(label='Tctl', current=62.375, high=None, critical=None), shwtemp(label='Tdie', current=62.375, high=None, critical=None)], 'amdgpu': [shwtemp(label='edge', current=62.0, high=80.0, critical=80.0)]}

Error output:

❯ sudo auto-cpufreq --monitor

----------------------------- System information ------------------------------

Linux distro: Manjaro Linux 20.0.3 Lysia
Linux kernel: 5.8.0-1-MANJARO
Driver: acpi-cpufreq
Architecture: x86_64
Processor: AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx
Cores: 8

------------------------------ Current CPU states ------------------------------

CPU max frequency: 2000MHz
CPU min frequency: 1600MHz
CPU frequency for each core:

CPU0: 2112 MHz
CPU1: 2154 MHz
CPU2: 2179 MHz
CPU3: 1861 MHz
CPU4: 1668 MHz
CPU5: 1556 MHz
CPU6: 2032 MHz
CPU7: 1867 MHz

Temperature for each physical core:

Traceback (most recent call last):
  File "/usr/sbin/auto-cpufreq", line 116, in <module>
    main()
  File "/usr/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/sbin/auto-cpufreq", line 67, in main
    sysinfo()
  File "/usr/lib/python3.8/site-packages/source/core.py", line 483, in sysinfo
    temp = core_temp['acpitz'][0].current
KeyError: 'acpitz'

System information:

-------------------------------------------------------------------------------

System:
  Kernel: 5.8.0-1-MANJARO x86_64 bits: 64 Desktop: GNOME 3.36.4 Distro: Manjaro Linux 
Machine:
  Type: Laptop System: Dell product: Inspiron 5575 v: 1.3.3 serial: <filter> 
  Mobo: Dell model: 0M0Y6P v: X01 serial: <filter> UEFI: Dell v: 1.3.3 
  date: 10/31/2019 
Battery:
  ID-1: BAT1 charge: 31.7 Wh condition: 31.7/42.0 Wh (76%) 
CPU:   Governors: performance schedutil
  type: MT MCP L2 cache: 2048 KiB 
  Speed: 2781 MHz min/max: 1600/2000 MHz Core speeds (MHz): 1: 1776 2: 1814 3: 1513 
  4: 1466 5: 1528 6: 1495 7: 2365 8: 1969 
Graphics:
  Device-1: AMD Raven Ridge [Radeon Vega Series / Radeon Vega Mobile Series] 
  driver: amdgpu v: kernel 
  Device-2: Realtek Integrated Webcam type: USB driver: uvcvideo 
  Display: x11 server: X.Org 1.20.8 driver: amdgpu unloaded: modesetting 
  resolution: 1920x1080~60Hz 
  OpenGL: renderer: AMD RAVEN (DRM 3.38.0 5.8.0-1-MANJARO LLVM 10.0.1) 
  v: 4.6 Mesa 20.1.4 
Audio:
  Device-1: AMD Raven/Raven2/Fenghuang HDMI/DP Audio driver: snd_hda_intel 
  Device-2: AMD Family 17h HD Audio driver: snd_hda_intel 
  Sound Server: ALSA v: k5.8.0-1-MANJARO 
Network:
  Device-1: Realtek RTL810xE PCI Express Fast Ethernet driver: r8169 
  IF: eth0 state: down mac: <filter> 
  Device-2: Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter 
  driver: ath10k_pci 
  IF: wlan0 state: up mac: <filter> 
  Device-3: Qualcomm Atheros type: USB driver: btusb 
Drives:
  Local Storage: total: 1.14 TiB used: 803.28 GiB (69.0%) 
  ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 970 EVO Plus 250GB size: 232.89 GiB 
  ID-2: /dev/sda vendor: Western Digital model: WD10SPZX-75Z10T2 size: 931.51 GiB 
Partition:
  ID-1: / size: 227.94 GiB used: 184.70 GiB (81.0%) fs: ext4 dev: /dev/nvme0n1p2 
Swap:
  ID-1: swap-1 type: file size: 20.00 GiB used: 83.2 MiB (0.4%) file: /swapfile 
Sensors:
  System Temperatures: cpu: 67.2 C mobo: N/A gpu: amdgpu temp: 67 C 
  Fan Speeds (RPM): cpu: 6200 fan-1: 
Info:
  Processes: 399 Uptime: 8h 21m Memory: 15.35 GiB used: 8.14 GiB (53.0%) Shell: Zsh 
  inxi: 3.1.05 

-------------------------------------------------------------------------------

FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/auto-cpufreq/scripts/auto-cpufreq-install.sh'

yay -S auto-cpufreq
sudo auto-cpufreq --install

Error output:

--------------------- Deploying auto-cpufreq as a daemon ----------------------

* Turn off bluetooth on boot

* Deploy auto-cpufreq install script
Traceback (most recent call last):
  File "/usr/bin/auto-cpufreq", line 115, in <module>
    main()
  File "/usr/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/bin/auto-cpufreq", line 98, in main
    deploy_daemon()
  File "/usr/lib/python3.8/site-packages/source/core.py", line 215, in deploy_daemon
    shutil.copy(SCRIPTS_DIR / "auto-cpufreq-install.sh", "/usr/bin/auto-cpufreq-install")
  File "/usr/lib/python3.8/shutil.py", line 415, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.8/shutil.py", line 261, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/share/auto-cpufreq/scripts/auto-cpufreq-install.sh'


System information:

-------------------------------------------------------------------------------

System: Hewlett-Packard product: HP EliteBook Folio 1040 G1 v: A3009D510203 
           serial: <filter> 
           Mobo: Hewlett-Packard model: 213E v: KBC Version 24.2B serial: <filter> 
           BIOS: Hewlett-Packard v: L83 Ver. 01.21 date: 08/19/2014 
Battery:   ID-1: BAT0 charge: 25.1 Wh condition: 31.1/31.1 Wh (100%) 
CPU:       Governors: performance powersave Topology: Dual Core model: Intel Core i5-4300U bits: 64 type: MT MCP L2 cache: 3072 KiB 
           Speed: 799 MHz min/max: 800/2500 MHz Core speeds (MHz): 1: 798 2: 798 3: 798 4: 798 
Graphics:  Device-1: Intel Haswell-ULT Integrated Graphics driver: i915 v: kernel 
           Display: x11 server: X.Org 1.20.8 driver: intel unloaded: modesetting,vesa 
           resolution: 1920x1080~60Hz 
           OpenGL: renderer: Mesa DRI Intel HD Graphics 4400 (HSW GT2) v: 4.5 Mesa 20.1.3 
Audio:     Device-1: Intel Haswell-ULT HD Audio driver: snd_hda_intel 
           Device-2: Intel 8 Series HD Audio driver: snd_hda_intel 
           Sound Server: ALSA v: k5.6.19-2-MANJARO 
Network:   Device-1: Intel Ethernet I218-LM driver: e1000e 
           IF: enp0s25 state: down mac: <filter> 
           Device-2: Intel Wireless 7260 driver: iwlwifi 
           IF: wlo1 state: up mac: <filter> 
Drives:    Local Storage: total: 167.68 GiB used: 13.97 GiB (8.3%) 
           ID-1: /dev/sda vendor: Intel model: SSDSCKGF180A4H size: 167.68 GiB 
Partition: ID-1: / size: 29.52 GiB used: 13.97 GiB (47.3%) fs: ext4 dev: /dev/sda3 
Sensors:   
{'battery': sbattery(percent=80.62789867998573, secsleft=11894, power_plugged=False),
 'fans': {},
 'temperatures:': {'acpitz': [shwtemp(label='', current=42.0, high=128.0, critical=128.0),
                              shwtemp(label='', current=0.0, high=128.0, critical=128.0),
                              shwtemp(label='', current=37.0, high=128.0, critical=128.0),
                              shwtemp(label='', current=36.0, high=128.0, critical=128.0),
                              shwtemp(label='', current=34.0, high=128.0, critical=128.0),
                              shwtemp(label='', current=114.0, high=128.0, critical=128.0)],
                   'coretemp': [shwtemp(label='Package id 0', current=43.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 0', current=37.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 1', current=42.0, high=100.0, critical=100.0),
                                shwtemp(label='Package id 0', current=43.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 0', current=37.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 1', current=42.0, high=100.0, critical=100.0)]}} System Temperatures: cpu: 37.0 C mobo: N/A 
           Fan Speeds (RPM): N/A 
Info:      Processes: 159 Uptime: 45m Memory: 7.68 GiB used: 1.11 GiB (14.5%) Shell: auto-cpufreq 
           inxi: 3.0.37 

-------------------------------------------------------------------------------


 ██████████████████  ████████     
 ██████████████████  ████████     OS: Manjaro 20.0.3 Lysia
 ██████████████████  ████████     Kernel: x86_64 Linux 5.6.19-2-MANJARO
 ██████████████████  ████████     Uptime: 55m
 ████████            ████████     Packages: 1041
 ████████  ████████  ████████     Shell: zsh 5.8
 ████████  ████████  ████████     Resolution: 1920x1080
 ████████  ████████  ████████     WM: i3
 ████████  ████████  ████████     GTK Theme: Adapta-Nokto-Eta-Maia [GTK2/3]
 ████████  ████████  ████████     Icon Theme: breeze
 ████████  ████████  ████████     Font: Noto Sans,  10
 ████████  ████████  ████████     Disk: 14G / 34G (44%)
 ████████  ████████  ████████     CPU: Intel Core i5-4300U @ 4x 2.5GHz [44.0°C]
 ████████  ████████  ████████     GPU: Mesa DRI Intel(R) HD Graphics 4400 (HSW GT2)
                                  RAM: 1453MiB / 7859MiB

Unable to copy to scripts/auto-cpufreq.service

Unable to copy the scripts/auto-cpufreq.service file to
/lib/systemd/system/auto-cpufreq.service in openSuse.

Correct path should be /usr/lib/systemd/system/auto-cpufreq.service.

Thanks for the auto-cpufreq.

Error starting

Hi, when I try to run your software I receive this error message:

andrea@andrea-X510UQR:~/.tmp/auto-cpufreq$ sudo python3 auto-cpufreq.py
 Traceback (most recent call last):
  File "auto-cpufreq.py", line 32, in <module>
    gov_state = get_cur_gov.split()[0]
IndexError: list index out of range

How can I resolve this? Thanks in advance!

ARM Devices

Traceback (most recent call last):
  File "auto-cpufreq.py", line 448, in <module>
    cli()
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "auto-cpufreq.py", line 421, in cli
    sysinfo()
  File "auto-cpufreq.py", line 349, in sysinfo
    print("CPU" + str(core_num) + " temp: {:.0f}".format(core_temp['coretemp'][core_num].current) + "°C")
KeyError: 'coretemp'

Seems that it can read the CPU temp easily fixed by adding

cat /sys/devices/virtual/thermal/thermal_zone0/temp

For checking temp if not available via the pypi packages :)

anyways thanks for a great tool

Systemd service fails on boot but can be manually started.

Systemd service fails on boot, but runs successfully when started manually (sudo systemctl start auto-cpufreq.service). Suspect that the service needs a different "After" target. Will dig further on my own.

System:
Arch Linux x86_64 5.4.8-arch1-1
Intel i5-4200U
Asus Q501LA 1.0

sudo systemctl status auto-cpufreq.service immediately after boot:

● auto-cpufreq.service - auto-cpufreq - Automatic CPU speed & power optimizer for Linux
     Loaded: loaded (/usr/lib/systemd/system/auto-cpufreq.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Tue 2020-01-07 18:31:17 MST; 15min ago
    Process: 474 ExecStart=/usr/bin/python3 /usr/bin/auto-cpufreq --daemon (code=exited, status=1/FAILURE)
   Main PID: 474 (code=exited, status=1/FAILURE)

Jan 07 18:31:17 orpheus systemd[1]: Started auto-cpufreq - Automatic CPU speed & power optimizer for Linux.
Jan 07 18:31:17 orpheus systemd[1]: auto-cpufreq.service: Main process exited, code=exited, status=1/FAILURE
Jan 07 18:31:17 orpheus systemd[1]: auto-cpufreq.service: Failed with result 'exit-code'.

energy_performance_preference doesn't change

TLP can, but auto-cpufreq doesn't.
Example:

+++ Processor
CPU model      = Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz

/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver    = intel_pstate
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor  = powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors = performance powersave
/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq  =   400000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq  =  1600000 [kHz]
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference = balance_power
/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences = default performance balance_performance balance_power power 

I removed the auto-cpufreq and configure TLP again. Without TLP, energy_performance_preference = balance_performance. scaling_governor is changing without any issue.

Import error when launching 'sudo auto-cpufreq --install'

Greetings,

OS: Ubuntu 19.10

Installed from source. Added required packages with PIP.
Tried to install and got error below

Traceback (most recent call last):
File "/usr/bin/auto-cpufreq", line 11, in
import psutil
File "/usr/local/lib/python3.7/dist-packages/psutil/init.py", line 96, in
from . import _pslinux as _psplatform
File "/usr/local/lib/python3.7/dist-packages/psutil/_pslinux.py", line 26, in
from . import _psutil_linux as cext
ImportError: /usr/local/lib/python3.7/dist-packages/psutil/_psutil_linux.cpython-37m-x86_64-linux-gnu.so: failed to map segment from shared object

Any help is much appreciated

Traceback when launching

I receive this traceback when running sudo python3 auto-cpufreq.py

Traceback (most recent call last): File "auto-cpufreq.py", line 382, in <module> @click.option("--daemon", is_flag=True, hidden=True) File "/usr/lib/python3/dist-packages/click/decorators.py", line 170, in decorator _param_memo(f, OptionClass(param_decls, **attrs)) File "/usr/lib/python3/dist-packages/click/core.py", line 1460, in __init__ Parameter.__init__(self, param_decls, type=type, **attrs) TypeError: __init__() got an unexpected keyword argument 'hidden'

PermissionError: [Errno 1] Operation not permitted

Error output:

auto-cpufreq --log 
CPU min frequency: 2300MHz

CPU frequency for each core:

CPU0: 2300 MHz
CPU1: 2300 MHz
CPU2: 2300 MHz
CPU3: 2300 MHz

Temperature for each physical core:

CPU0 temp: 53°C
CPU1 temp: 53°C

---------------------------- CPU frequency scaling ----------------------------

Battery is: charging
Setting to use: "performance" governor
Setting to use: "balance_performance" EPP

Total CPU usage: 10.6 %
Total system load: 2.29 

High load, setting turbo boost: on
PermissionError: [Errno 1] Operation not permitted

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/snap/auto-cpufreq/14/bin/auto-cpufreq", line 115, in <module>
    main()
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/auto-cpufreq/14/bin/auto-cpufreq", line 42, in main
    set_autofreq()
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/source/core.py", line 402, in set_autofreq
    set_performance()
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/source/core.py", line 362, in set_performance
    turbo(True)
  File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/source/core.py", line 52, in turbo
    f.write_text(str(int(value)) + "\n")
  File "/snap/auto-cpufreq/14/usr/lib/python3.6/pathlib.py", line 1216, in write_text
    return f.write(data)
PermissionError: [Errno 1] Operation not permitted
^C
Aborted!

System information:

auto-cpufreq --debug

-------------------------------------------------------------------------------

System: Notebook product: N24_25JU serial: N/A
           Mobo: Notebook model: N24_25JU serial: N/A UEFI: American Megatrends v: 5.11 date: 03/31/2016
Battery    BAT0: charge: 40.5 Wh 100.0% condition: 40.5/43.1 Wh (94%)
           hidpp__3: charge: N/A condition: NA/NA Wh
CPU:       Governors: performance powersave Dual core Intel Core i3-6100U (-MT-MCP-) cache: 3072 KB
           clock speeds: max: 2300 MHz 1: 2297 MHz 2: 2298 MHz 3: 2293 MHz 4: 2295 MHz
Graphics:  Card: Intel Skylake GT2 [HD Graphics 520]
           Display Server: N/A drivers: modesetting (unloaded: fbdev,vesa) tty size: 168x41
Audio:     Card Intel Sunrise Point-LP HD Audio driver: snd_hda_intel
           Sound: Advanced Linux Sound Architecture v: k5.6.14-050614-generic
Network:   Card-1: Realtek RTL8111/8168/8411 PCIE Gigabit Ethernet Controller driver: r8169
           IF: enp1s0f1 state: down mac: <filter>
           Card-2: Intel Wireless 8260 driver: iwlwifi
           IF: wlp2s0 state: up mac: <filter>
Drives:    HDD Total Size: 2120.4GB (41.8% used)
           ID-1: /dev/sdb model: WDC_WDS120G1G0B size: 120.0GB
           ID-2: /dev/sda model: ST2000LX001 size: 2000.4GB
Partition: ID-1: /var/log size: 19G used: 1.2G (7%) fs: zfs dev: N/A
           ID-2: swap-1 size: 4.29GB used: 0.00GB (0%) fs: swap dev: /dev/zd0
           ID-3: swap-2 size: 2.15GB used: 0.00GB (0%) fs: swap dev: /dev/sdb2
           ID-4: swap-3 size: 1.56GB used: 0.10GB (7%) fs: swap dev: /dev/zram0
           ID-5: swap-4 size: 1.56GB used: 0.10GB (7%) fs: swap dev: /dev/zram1
           ID-6: swap-5 size: 1.56GB used: 0.10GB (7%) fs: swap dev: /dev/zram2
           ID-7: swap-6 size: 1.56GB used: 0.10GB (7%) fs: swap dev: /dev/zram3
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   
{'battery': sbattery(percent=100.0, secsleft=<BatteryTime.POWER_TIME_UNLIMITED: -2>, power_plugged=True),
 'fans': {},
 'temperatures:': {'acpitz': [shwtemp(label='', current=49.0, high=120.0, critical=120.0)],
                   'coretemp': [shwtemp(label='Package id 0', current=52.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 0', current=47.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 1', current=52.0, high=100.0, critical=100.0),
                                shwtemp(label='Package id 0', current=52.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 0', current=47.0, high=100.0, critical=100.0),
                                shwtemp(label='Core 1', current=52.0, high=100.0, critical=100.0)],
                   'iwlwifi_1': [shwtemp(label='', current=44.0, high=None, critical=None)]}} System Temperatures: cpu: 51.0C mobo: N/A
           Fan Speeds (in rpm): cpu: N/A
Info:      Processes: 474 Uptime: 2 days Memory: 9981.7/11899.3MB Init: systemd runlevel: 5
           Client: Unknown python3.6 client inxi: 2.3.56

-------------------------------------------------------------------------------

Syslog

Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Linux distro: Ubuntu 20.04.1 LTS (Focal Fossa)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Linux kernel: 5.6.14-050614-generic
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Driver: intel_pstate
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Architecture: x86_64
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Processor: Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Cores: 4
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: ------------------------------ Current CPU states ------------------------------
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU max frequency: 2300MHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU min frequency: 2300MHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU frequency for each core:
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU0: 2300 MHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU1: 2300 MHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU2: 2300 MHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU3: 2300 MHz
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Temperature for each physical core:
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU0 temp: 53°C
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: CPU1 temp: 53°C
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: ---------------------------- CPU frequency scaling ----------------------------
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Battery is: charging
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Setting to use: "performance" governor
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Setting to use: "balance_performance" EPP
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Total CPU usage: 10.6 %
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Total system load: 2.29
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: High load, setting turbo boost: on
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: PermissionError: [Errno 1] Operation not permitted
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: During handling of the above exception, another exception occurred:
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: Traceback (most recent call last):
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/bin/auto-cpufreq", line 115, in <module>
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     main()
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 829, in __call__
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     return self.main(*args, **kwargs)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 782, in main
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     rv = self.invoke(ctx)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     return ctx.invoke(self.callback, **ctx.params)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/click/core.py", line 610, in invoke
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     return callback(*args, **kwargs)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/bin/auto-cpufreq", line 42, in main
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     set_autofreq()
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/source/core.py", line 402, in set_autofreq
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     set_performance()
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/source/core.py", line 362, in set_performance
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     turbo(True)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/lib/python3.6/site-packages/source/core.py", line 52, in turbo
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     f.write_text(str(int(value)) + "\n")
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:   File "/snap/auto-cpufreq/14/usr/lib/python3.6/pathlib.py", line 1216, in write_text
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]:     return f.write(data)
Aug  7 08:49:39 kwaadpepper-N24-25JU auto-cpufreq.service[1519481]: PermissionError: [Errno 1] Operation not permitted
Aug  7 08:49:39 kwaadpepper-N24-25JU systemd[1]: snap.auto-cpufreq.service.service: Succeeded.
Aug  7 08:49:39 kwaadpepper-N24-25JU tracker-store[1516511]: OK
Aug  7 08:49:39 kwaadpepper-N24-25JU systemd[4954]: tracker-store.service: Succeeded.
Aug  7 08:51:31 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_full (No such file or directory)
Aug  7 08:51:31 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_now (No such file or directory)
Aug  7 08:51:31 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power_now (No such file or directory)
Aug  7 08:51:31 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/energy_full (No such file or directory)
Aug  7 08:51:31 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/charge_full (No such file or directory)
Aug  7 08:51:31 kwaadpepper-N24-25JU cpufreqd: acpi_battery_init        : Couldn't open hidpp_battery_3 attributes
Aug  7 08:52:04 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_full (No such file or directory)
Aug  7 08:52:04 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_now (No such file or directory)
Aug  7 08:52:04 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power_now (No such file or directory)
Aug  7 08:52:04 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/energy_full (No such file or directory)
Aug  7 08:52:04 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/charge_full (No such file or directory)
Aug  7 08:52:04 kwaadpepper-N24-25JU cpufreqd: acpi_battery_init        : Couldn't open hidpp_battery_3 attributes
Aug  7 08:52:41 kwaadpepper-N24-25JU wpa_supplicant[2908]: wlp2s0: CTRL-EVENT-SIGNAL-CHANGE above=1 signal=-37 noise=9999 txrate=866700
Aug  7 08:53:07 kwaadpepper-N24-25JU PackageKit: daemon quit
Aug  7 08:53:07 kwaadpepper-N24-25JU systemd[1]: packagekit.service: Succeeded.
Aug  7 08:54:51 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_full (No such file or directory)
Aug  7 08:54:51 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_now (No such file or directory)
Aug  7 08:54:51 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power_now (No such file or directory)
Aug  7 08:54:51 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/energy_full (No such file or directory)
Aug  7 08:54:51 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/charge_full (No such file or directory)
Aug  7 08:54:51 kwaadpepper-N24-25JU cpufreqd: acpi_battery_init        : Couldn't open hidpp_battery_3 attributes
Aug  7 08:55:47 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_full (No such file or directory)
Aug  7 08:55:47 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/energy_now (No such file or directory)
Aug  7 08:55:47 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/power_now (No such file or directory)
Aug  7 08:55:47 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/energy_full (No such file or directory)
Aug  7 08:55:47 kwaadpepper-N24-25JU cpufreqd: get_class_device_attribute: couldn't open /sys/devices/pci0000:00/0000:00:14.0/usb1/1-3/1-3:1.2/0003:046D:C52B.0013/0003:046D:4072.0015/power_supply/hidpp_battery_3/charge_full (No such file or directory)

Strange system error

I suddenly start to see that messages appeared from time to time (exact conditions are not yet clear, once it appeared after restoring from the hibernation, another time just in the middle of a running session, literally in all console/terminal window covering whatever is there at the moment):

(base) alex@precision:~$
Message from syslogd@precision at Jan  7 18:27:59 ...
 kernel:[30691.577644] Uhhuh. NMI received for unknown reason 3c on CPU 0.

Message from syslogd@precision at Jan  7 18:27:59 ...
 kernel:[30691.577645] Do you have a strange power saving mode enabled?

Message from syslogd@precision at Jan  7 18:27:59 ...
 kernel:[30691.577646] Dazed and confused, but trying to continue

Not necessary this is related to auto-cpufreq. Could it be related to tlp as this was the only relevant package I installed recently and which also potentially could cause this?

[Feature] add Flatpak support

As far as we know that not all linux distribution uses snap by default.
I think that adding flatpak package would be a nice addition for the RHEL/Fedora/Silverblue/CentOS users and others (clear linux, POP OS, and other who relise on flatpak as default)

I have a bit of experience with flatpak, so can try to look in that direction.

@AdnanHodzic if you consider flatpak support, than you can assign this issue to me.

Permission denied with snap

Hello ! I'm testing this program, but so far, so good. Although, I found a problem and resolved it.
When I first installed it with 'snap', when running with 'sudo the auto-cpufreq --live', I was getting permission denied when trying to make changes.
I removed it and re-installed using the source code. Then, everything changed as supposed too.

[my small contribution, even though I don't now if it's a know issue...]
Cheers!

Daemon cannot start on Manjaro

I've installed auto-cpufreq on my up-to-date Manjaro machine with snap:

snap     2.44.1-1
snapd    2.44-1
series   16
manjaro  -
kernel   4.19.112-1-MANJARO

Installation goes well, but things go wrong when I try to start the daemon. This is from system logs:

Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]: ----------------------------- System information ------------------------------
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]: Traceback (most recent call last):
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/bin/auto-cpufreq", line 108, in <module>
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     main()
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 829, in __call__
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     return self.main(*args, **kwargs)
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 782, in main
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     rv = self.invoke(ctx)
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     return ctx.invoke(self.callback, **ctx.params)
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 610, in invoke
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     return callback(*args, **kwargs)
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/bin/auto-cpufreq", line 39, in main
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     sysinfo()
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:   File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/source/core.py", line 360, in sysinfo
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]:     dist = distro + " " + version
Mar 29 14:56:22 rocinante auto-cpufreq.service[1881264]: UnboundLocalError: local variable 'version' referenced before assignment

I did a bit of digging and found that the core.py script is failing due to not being able to locate the searchfile at /var/lib/snapd/hostfs/etc/os-release. The bug here seems that it assumes the file is always present (which it seems not on my system), and if the file is not present then the version and distro variables go uninitialised. Looking at that path on my machine, I have an empty directory at /var/lib/snapd/hostfs.

Auto installer failed to install python, won't run


-------------------------- auto-cpufreq installer -----------------------------

Welcome to auto-cpufreq tool installer.

Options:

[I]nstall
[R]emove
[Q]uit

Select a key: [i/r/q]: i

-------------------------------------------------------------------------------

Detected Debian based distribution

-------------------------------------------------------------------------------

Setting up Python environment

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-dev is already the newest version (3.6.7-1~18.04).
python3-pip is already the newest version (9.0.1-2.3~ubuntu1.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

-------------------------------------------------------------------------------

Installing necessary Python packages

The directory '/home/fireflower/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/fireflower/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: psutil in /usr/lib/python3/dist-packages
Collecting click
  Downloading https://files.pythonhosted.org/packages/dd/c0/4d8f43a9b16e289f36478422031b8a63b54b6ac3b1ba605d602f10dd54d6/click-7.1.1-py2.py3-none-any.whl (82kB)
    100% |████████████████████████████████| 92kB 4.6MB/s 
Collecting distro
  Downloading https://files.pythonhosted.org/packages/25/b7/b3c4270a11414cb22c6352ebc7a83aaa3712043be29daa05018fd5a5c956/distro-1.5.0-py2.py3-none-any.whl
Collecting power
  Downloading https://files.pythonhosted.org/packages/6a/fc/a730a7c7a9a30b8e0774ca7e06c54181f61620250749ac3de47da138cfd4/power-1.4.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-3uuw_wzv/power/

-------------------------------------------------------------------------------

installing auto-cpufreq tool

Traceback (most recent call last):
  File "setup.py", line 3, in <module>
    from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'

-------------------------------------------------------------------------------

auto-cpufreq tool successfully installed.

For list of options, run:
auto-cpufreq

-------------------------------------------------------------------------------
fireflower@romuluotain8:

Seems like python installation failed and automatic installation failed with it but reports successful installation.

UserWarning: Unable to read properties of /sys/class/power_supply/hidpp_battery_0: [Errno 2]

Hi,

With a fresh install today, I get this when I launch auto-cpufreq

$ sudo auto-cpufreq 
/usr/local/lib/python3.6/dist-packages/power/linux.py:100: UserWarning: Unable to read properties of /sys/class/power_supply/hidpp_battery_0: [Errno 2] No such file or directory: '/sys/class/power_supply/hidpp_battery_0/present'
  warnings.warn("Unable to read properties of {path}: {error}".format(path=supply_path, error=str(e)))
Traceback (most recent call last):
  File "/usr/local/bin/auto-cpufreq", line 4, in <module>
    __import__('pkg_resources').run_script('auto-cpufreq==1.0', 'auto-cpufreq')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1445, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python3.6/dist-packages/auto_cpufreq-1.0-py3.6.egg/EGG-INFO/scripts/auto-cpufreq", line 20, in <module>
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 170, in decorator
    _param_memo(f, OptionClass(param_decls, **attrs))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1460, in __init__
    Parameter.__init__(self, param_decls, type=type, **attrs)
TypeError: __init__() got an unexpected keyword argument 'hidden'

Context:

  • DELL XPS 13 / i7-8550U
  • Ubuntu 18.04.4

psutil has no attribute 'sensors_battery'

Even after I fix errors due to the fact that certain distros don't have /usr/lib/systemd/system/ and instead have /lib/systemd/system/, I still encounter error with psutil.
Screenshot from 2020-01-06 12-16-50

Gamemode compatibility

Hi there!
I just installed a fresh ubuntu 20.04 copy.
I'm running your app, and i'm liking it so much...i'm not even going to install TLP.
So... there's also gamemode in ubuntu. As far as as i know, running gamemode, will change your governor to performance ( and so does your app when plugged to ac).
ubuntu's game mode will disable the performance governor when you exit the game. In this case, as i'm still plugged to ac, how will your app respond?
these 2 won't play well together right? do i need gamemode anyway?
cheers

ERROR: /etc/systemd/system/auto-cpufreq.service:9: Executable path is not absolute: auto-cpufreq --daemon

Hi,
firstly thank you for this amazing tool for Linux, in the past days I used the previous version with any issues (except for the log freeze), today I saw the new update and I followed the new installation instructions.
With the new installer I encoutered this pip warning:

WARNING: The directory '/home/filip/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

After that the installation was completed and fine.
But when I give the sudo auto-cpufreq --install instruction and after that, I check the systemctl status auto-cpufreq I receive the error in the title:
/etc/systemd/system/auto-cpufreq.service:9: Executable path is not absolute: auto-cpufreq --daemon

My OS is Elementary 5.1.2 (based on Ubuntu 18.04 LTS)

Thank you in advance for your help!

auto-cpufreq --log seems stopped working

I cannot be able to see the stream of the log. It just stopped with the following content:


----------------------------- System information ------------------------------

Linux distro: Ubuntu 20.04 Focal Fossa
Linux kernel: 5.0.0-37-generic
Driver: intel_pstate
Architecture: x86_64
Processor: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
Cores: 8

------------------------------ Current CPU states ------------------------------

CPU max frequency: 
3900 MHz

CPU frequency for each core:

CPU0: 3114 MHz
CPU1: 3175 MHz
CPU2: 3301 MHz
CPU3: 3556 MHz
CPU4: 3242 MHz
CPU5: 2934 MHz
CPU6: 3488 MHz
CPU7: 3382 MHz

Temperature for each physical core:

CPU0 temp: 44°C
CPU1 temp: 40°C
CPU2 temp: 41°C
CPU3 temp: 44°C

---------------------------- CPU frequency scaling ----------------------------

Battery is: charging
Setting to use "performance" governor

Total CPU usage: 3.2 %
Total system load: 0.34 

Setting turbo boost: on

-------------------------------------------------------------------------------

			"auto-cpufreq" refresh in: 2


But right now I'm not on the charging status, that machine goes with the battery.

● auto-cpufreq.service - auto-cpufreq - Automatic CPU speed & power optimizer f>
     Loaded: loaded (/lib/systemd/system/auto-cpufreq.service; enabled; vendor >
     Active: active (running) since Sun 2020-01-05 14:00:51 +03; 24min ago
   Main PID: 1843 (python3)
      Tasks: 1 (limit: 9195)
     Memory: 19.3M
     CGroup: /system.slice/auto-cpufreq.service
             └─1843 /usr/bin/python3 /usr/bin/auto-cpufreq --daemon

Cannot --install auto-cpufreq

I just installed auto-cpugreq from AUR on Manjaro and decided to use --install after I tested it live, however I'm getting this output

[~] sudo auto-cpufreq --install

--------------------- Deploying auto-cpufreq as a daemon ----------------------

* Turn off bluetooth on boot

* Deploy auto-cpufreq as system wide accessible binary
cp: cannot stat 'auto-cpufreq.py': No such file or directory

* Deploy auto-cpufreq install script
cp: cannot stat 'scripts/auto-cpufreq-install.sh': No such file or directory

* Deploy auto-cpufreq remove script
cp: cannot stat 'scripts/auto-cpufreq-remove.sh': No such file or directory
/bin/sh: /usr/bin/auto-cpufreq-install: No such file or directory

I've been trying to search for the file "auto-cpufreq-remove.sh" with no results at all.

Permission denied on Snap 2.44.3+20.04

Hi!

Using auto-cpufreq --log after a successful sudo auto-cpufreq --install, I get the following error:

⋊> ~ auto-cpufreq --log

-------------------------------- Daemon check ---------------------------------

ERROR:

Daemon not enabled, must run install first, i.e:
sudo auto-cpufreq --install

-------------------------------------------------------------------------------


----------------------------- System information ------------------------------

Traceback (most recent call last):
  File "/snap/auto-cpufreq/5/bin/auto-cpufreq", line 108, in <module>
    main()
  File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/auto-cpufreq/5/bin/auto-cpufreq", line 39, in main
    sysinfo()
  File "/snap/auto-cpufreq/5/lib/python3.6/site-packages/source/core.py", line 351, in sysinfo
    searchfile = open("/var/lib/snapd/hostfs/etc/os-release", "r")
PermissionError: [Errno 13] Permission denied: '/var/lib/snapd/hostfs/etc/os-release'

Tried the command with sudo, same result.

TypeError: __init__() got an unexpected keyword argument 'hidden'

Hi.

I just cloned the repo, installed dependencies and run the script but got a TypeError:

> sudo python3 auto-cpufreq.py
Traceback (most recent call last):
  File "auto-cpufreq.py", line 382, in <module>
    @click.option("--daemon", is_flag=True, hidden=True)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 170, in decorator
    _param_memo(f, OptionClass(param_decls, **attrs))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1460, in __init__
    Parameter.__init__(self, param_decls, type=type, **attrs)
TypeError: __init__() got an unexpected keyword argument 'hidden'

I am using Linux Mint 19.3.

AUR package not working with python virtualenv

To bring stability to my system, I use virtualenv to install all python tools through package managers like pip. When installing the auto-cpufreq-git package from the AUR, I noticed that it installed the auto-cpufreq binary into my user space virtualenv:

$ which auto-cpufreq
/home/marco/.virtualenv/bin/auto-cpufreq

When the auto-cpufreq service is started with systemctl it borks with the following:

● auto-cpufreq.service - auto-cpufreq - Automatic CPU speed & power optimizer for Linux
     Loaded: bad-setting (Reason: Unit auto-cpufreq.service has a bad unit file setting.)
     Active: inactive (dead)

Mar 24 11:09:21 rocinante systemd[1]: /usr/lib/systemd/system/auto-cpufreq.service:9: Executable "auto-cpufreq" not found in path "/usr/local/bin:/usr/bin"
Mar 24 11:09:21 rocinante systemd[1]: auto-cpufreq.service: Unit configuration has fatal error, unit will not be started.
Mar 24 11:10:12 rocinante systemd[1]: /usr/lib/systemd/system/auto-cpufreq.service:9: Executable "auto-cpufreq" not found in path "/usr/local/bin:/usr/bin"
Mar 24 11:10:12 rocinante systemd[1]: auto-cpufreq.service: Unit configuration has fatal error, unit will not be started.

Battery appears as Charging while not

Error output:

--> Battery is: charging
Battery appears as "charging" while not ! My computer was not charging at all.


System information:


System: HP product: HP EliteBook 830 G5 v: N/A serial:
Mobo: HP model: 83B3 v: KBC Version 04.65.00 serial: UEFI: HP
v: Q78 Ver. 01.10.01 date: 03/02/2020
Battery: ID-1: BAT0 charge: 20.7 Wh condition: 47.3/47.3 Wh (100%)
CPU: Governors: performance powersave Topology: Dual Core model: Intel Core i5-7300U bits: 64 type: MT MCP
L2 cache: 3072 KiB
Speed: 1611 MHz min/max: 400/2600 MHz Core speeds (MHz): 1: 1751 2: 1895 3: 1857
4: 1802
Graphics: Device-1: Intel HD Graphics 620 driver: i915 v: kernel
Device-2: Lite-On HP HD Camera type: USB driver: uvcvideo
Display: server: X.Org 1.20.8 driver: intel unloaded: modesetting,vesa
resolution: 1920x1080~60Hz
OpenGL: renderer: Mesa Intel HD Graphics 620 (KBL GT2) v: 4.6 Mesa 20.1.4
Audio: Device-1: Intel Sunrise Point-LP HD Audio driver: snd_hda_intel
Sound Server: ALSA v: k5.7.12-arch1-1
Network: Device-1: Intel Ethernet I219-LM driver: e1000e
IF: enp0s31f6 state: down mac:
Device-2: Intel Wireless 8265 / 8275 driver: iwlwifi
IF: wlp1s0 state: up mac:
Drives: Local Storage: total: 238.47 GiB used: 110.49 GiB (46.3%)
ID-1: /dev/sda vendor: Micron model: MTFDDAV256TBN-1AR15ABHA size: 238.47 GiB
Partition: ID-1: / size: 229.28 GiB used: 110.38 GiB (48.1%) fs: ext4 dev: /dev/dm-2
ID-2: /boot size: 511.0 MiB used: 109.7 MiB (21.5%) fs: vfat dev: /dev/sda1
Swap: ID-1: swap-1 type: partition size: 4.00 GiB used: 0 KiB (0.0%) dev: /dev/dm-1
Sensors:
{'battery': None,
'fans': {},
'temperatures:': {'acpitz': [shwtemp(label='', current=30.0, high=None, critical=None),
shwtemp(label='', current=39.0, high=128.0, critical=128.0),
shwtemp(label='', current=0.0, high=128.0, critical=128.0),
shwtemp(label='', current=33.0, high=128.0, critical=128.0),
shwtemp(label='', current=33.0, high=128.0, critical=128.0),
shwtemp(label='', current=31.0, high=128.0, critical=128.0),
shwtemp(label='', current=33.0, high=128.0, critical=128.0),
shwtemp(label='', current=0.0, high=128.0, critical=128.0)],
'coretemp': [shwtemp(label='Package id 0', current=42.0, high=100.0, critical=100.0),
shwtemp(label='Core 0', current=42.0, high=100.0, critical=100.0),
shwtemp(label='Core 1', current=39.0, high=100.0, critical=100.0),
shwtemp(label='Package id 0', current=42.0, high=100.0, critical=100.0),
shwtemp(label='Core 0', current=42.0, high=100.0, critical=100.0),
shwtemp(label='Core 1', current=39.0, high=100.0, critical=100.0)],
'iwlwifi_1': [shwtemp(label='', current=44.0, high=None, critical=None)],
'pch_skylake': [shwtemp(label='', current=36.5, high=None, critical=None)]}} System Temperatures: cpu: 44.0 C mobo: 39.0 C
Fan Speeds (RPM): N/A
Info: Processes: 240 Uptime: 4h 19m Memory: 15.49 GiB used: 2.17 GiB (14.0%) Shell: Sudo
inxi: 3.1.04



AttributeError: 'NoneType' object has no attribute 'power_plugged'

My laptop is fully charged, and connected to the socket, and when run auto-cpufreq --log see the following error:

Traceback (most recent call last):
  File "/usr/bin/auto-cpufreq", line 437, in <module>
    cli()
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/bin/auto-cpufreq", line 401, in cli
    set_autofreq()
  File "/usr/bin/auto-cpufreq", line 243, in set_autofreq
    bat_state = p.sensors_battery().power_plugged
AttributeError: 'NoneType' object has no attribute 'power_plugged'

failed to install from aur

install: cannot stat 'auto-cpufreq.py': No such file or directory
==> ERROR: A failure occurred in package().
Aborting...
Error making: auto-cpufreq-git

I got this error, is there a fix?

Service started but log not showed

I installed the last version of your code with manually installation. After installation without errors, I tried monitor and live and perfectly works. I decide to install it with the proper command and all works. The problem born when I try to execute the log command to see the configuration, but nothing showed. I see that service is running but I can't see the current configuration. Can you help me?

The battery is "discharging" even when connected to power.

Error output:

No errors

System information:

Manjaro

System: Micro-Star product: Alpha 15 A3DD v: REV:1.0 serial: <filter> 
           Mobo: Micro-Star model: MS-16U6 v: REV:1.0 serial: <filter> UEFI: American Megatrends v: E16U6AMS.110 
           date: 05/20/2020 
Battery:   ID-1: BAT1 charge: 48.0 Wh condition: 51.0/53.4 Wh (96%) 
CPU:       Governors: performance schedutil Topology: Quad Core model: AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx bits: 64 type: MT MCP L2 cache: 2048 KiB 
           Speed: 1202 MHz min/max: 1400/2300 MHz Core speeds (MHz): 1: 1190 2: 1201 3: 1613 4: 1707 5: 1492 6: 1451 7: 1231 
           8: 1395 
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Navi 14 [Radeon RX 5500/5500M / Pro 5500M] driver: amdgpu v: kernel 
           Device-2: Advanced Micro Devices [AMD/ATI] Picasso driver: amdgpu v: kernel 
           Display: server: X.org 1.20.8 driver: amdgpu,ati unloaded: modesetting,radeon resolution: <xdpyinfo missing> 
           Message: Advanced graphics data unavailable for root. 
Audio:     Device-1: Advanced Micro Devices [AMD/ATI] Navi 10 HDMI Audio driver: snd_hda_intel 
           Device-2: Advanced Micro Devices [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor driver: snd_rn_pci_acp3x 
           Device-3: Advanced Micro Devices [AMD] Family 17h HD Audio driver: snd_hda_intel 
           Sound Server: ALSA v: k5.8.0-1-MANJARO 
Network:   Device-1: Realtek RTL8822CE 802.11ac PCIe Wireless Network Adapter driver: rtw_8822ce 
           IF: wlo1 state: down mac: <filter> 
           Device-2: Realtek driver: r8169 
           IF: enp6s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
Drives:    Local Storage: total: 942.70 GiB used: 122.96 GiB (13.0%) 
           ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLB512HAJQ-00000 size: 476.94 GiB 
           ID-2: /dev/sda vendor: Crucial model: CT500MX500SSD1 size: 465.76 GiB 
Partition: ID-1: / size: 457.16 GiB used: 122.96 GiB (26.9%) fs: ext4 dev: /dev/sda2 
Sensors:   
{'battery': sbattery(percent=94.12644169158479, secsleft=<BatteryTime.POWER_TIME_UNKNOWN: -1>, power_plugged=None),
 'fans': {'amdgpu': [sfan(label='', current=65535)]},
 'temperatures:': {'acpitz': [shwtemp(label='', current=56.0, high=100.0, critical=100.0)],
                   'amdgpu': [shwtemp(label='edge', current=40.0, high=108.0, critical=108.0),
                              shwtemp(label='junction', current=40.0, high=99.0, critical=99.0),
                              shwtemp(label='mem', current=42.0, high=99.0, critical=99.0),
                              shwtemp(label='edge', current=53.0, high=80.0, critical=80.0)],
                   'k10temp': [shwtemp(label='Tctl', current=53.0, high=None, critical=None),
                               shwtemp(label='Tdie', current=53.0, high=None, critical=None)],
                   'nvme': [shwtemp(label='Composite', current=52.85, high=80.85, critical=81.85),
                            shwtemp(label='Sensor 1', current=52.85, high=65261.85, critical=65261.85),
                            shwtemp(label='Sensor 2', current=36.85, high=65261.85, critical=65261.85)]}} System Temperatures: cpu: 51.4 C mobo: N/A 
           Fan Speeds (RPM): N/A 
           GPU: device: amdgpu temp: 54 C fan: 65535 device: amdgpu temp: 51 C 
Info:      Processes: 289 Uptime: 3h 40m Memory: 29.37 GiB used: 4.69 GiB (16.0%) Shell: auto-cpufreq inxi: 3.0.37

/usr/bin >>> upower -i /org/freedesktop/UPower/devices/battery_BAT1                                                                                                                                                                                    [130]
  native-path:          BAT1
  vendor:               MSI
  model:                BIF0_9
  power supply:         yes
  updated:              pią, 7 sie 2020, 16:52:33 (16 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               fully-charged
    warning-level:       none
    energy:              47,86 Wh
    energy-empty:        0 Wh
    energy-full:         50,8465 Wh
    energy-full-design:  53,2357 Wh
    energy-rate:         0,0465847 W
    voltage:             12,113 V
    percentage:          94%
    capacity:            95,512%
    technology:          lithium-ion
    icon-name:          'battery-full-charged-symbolic'

I don't know if it's an error (translation), but according to auto-cpufreq (as I understand it), the battery is discharged even when it is plugged in. In my opinion the program can take bad values in boost management and so on (although I don't see that it would change anything).

Unless I'm stupid and I misunderstand something.

[feature request/enhancement] settings file

Would it be a good idea to have a settings file?

Certain things could be stored here like;

  • minimum CPU load before going to turbo
  • minimum load factor before going to turbo
  • true/false for allowing turboboost to be switched off when on battery
    And any other items that can be changed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.