Skip to content

Commit

Permalink
Improved power_helper snap package detection
Browse files Browse the repository at this point in the history
  • Loading branch information
AdnanHodzic committed Feb 20, 2022
1 parent a15e594 commit f65dba3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ This can be done by running: `sudo python3 power_helper.py --gnome_power_disable

After auto-cpufreq git repo has been cloned (`git clone https://github.com/AdnanHodzic/auto-cpufreq.git`), navagiate to directory where `power_helper.py` script resides by running: `cd auto-cpufreq/auto_cpufreq`

After this step, all necessary changes will still be made automatically. However, if you wish to perform additonal "manual" settings this can be done by following instrucitons explained in next step.
After this step, all necessary changes will still be made automatically. However, if you wish to perform additonal "manual" settings this can be done by following instructions explained in next step.

### 2: auto-cpufreq config file

Expand Down
8 changes: 6 additions & 2 deletions auto_cpufreq/power_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def does_command_exists(cmd):
bluetoothctl_exists = does_command_exists("bluetoothctl")
tlp_stat_exists = does_command_exists("tlp-stat")
powerprofilesctl_exists = does_command_exists("powerprofilesctl")
snap_check = os.system("snap list | grep auto-cpufreq >/dev/null 2>&1")


# detect if gnome power profile service is running
if os.getenv("PKG_MARKER") != "SNAP":
Expand Down Expand Up @@ -281,7 +283,8 @@ def gnome_power_svc_disable_ext(ctx, power_selection):
if systemctl_exists:
# 0 is active
if gnome_power_status != 0:
if os.getenv("PKG_MARKER") == "SNAP":
# 0 is success (snap package is installed)
if snap_check == 0:
print("Power Profiles Daemon is already disabled, re-enable by running:\n"
"sudo python3 power_helper.py --gnome_power_enable\n"
"\nfollowed by running:\n"
Expand All @@ -296,7 +299,8 @@ def gnome_power_svc_disable_ext(ctx, power_selection):

# set balanced profile if its running before disabling it
if gnome_power_status == 0 and powerprofilesctl_exists:
if os.getenv("PKG_MARKER") == "SNAP":
# 0 is success (snap package is installed)
if snap_check == 0:
print("Using profile: ", gnome_power_disable)
call(["powerprofilesctl", "set", gnome_power_disable])

Expand Down

0 comments on commit f65dba3

Please sign in to comment.