Skip to content

Commit f65dba3

Browse files
committed
Improved power_helper snap package detection
1 parent a15e594 commit f65dba3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ This can be done by running: `sudo python3 power_helper.py --gnome_power_disable
8686

8787
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`
8888

89-
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.
89+
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.
9090

9191
### 2: auto-cpufreq config file
9292

auto_cpufreq/power_helper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def does_command_exists(cmd):
3333
bluetoothctl_exists = does_command_exists("bluetoothctl")
3434
tlp_stat_exists = does_command_exists("tlp-stat")
3535
powerprofilesctl_exists = does_command_exists("powerprofilesctl")
36+
snap_check = os.system("snap list | grep auto-cpufreq >/dev/null 2>&1")
37+
3638

3739
# detect if gnome power profile service is running
3840
if os.getenv("PKG_MARKER") != "SNAP":
@@ -281,7 +283,8 @@ def gnome_power_svc_disable_ext(ctx, power_selection):
281283
if systemctl_exists:
282284
# 0 is active
283285
if gnome_power_status != 0:
284-
if os.getenv("PKG_MARKER") == "SNAP":
286+
# 0 is success (snap package is installed)
287+
if snap_check == 0:
285288
print("Power Profiles Daemon is already disabled, re-enable by running:\n"
286289
"sudo python3 power_helper.py --gnome_power_enable\n"
287290
"\nfollowed by running:\n"
@@ -296,7 +299,8 @@ def gnome_power_svc_disable_ext(ctx, power_selection):
296299

297300
# set balanced profile if its running before disabling it
298301
if gnome_power_status == 0 and powerprofilesctl_exists:
299-
if os.getenv("PKG_MARKER") == "SNAP":
302+
# 0 is success (snap package is installed)
303+
if snap_check == 0:
300304
print("Using profile: ", gnome_power_disable)
301305
call(["powerprofilesctl", "set", gnome_power_disable])
302306

0 commit comments

Comments
 (0)