Skip to content

Commit

Permalink
Add support for Fedora 41 (TuneD) | #786
Browse files Browse the repository at this point in the history
  • Loading branch information
geragio authored Nov 2, 2024
1 parent 7b03630 commit 6a13948
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ The AUR [Release Package](https://aur.archlinux.org/packages/auto-cpufreq) is cu
```
- The GNOME Power Profiles daemon is [automatically disabled by auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq#1-power_helperpy-script-snap-package-install-only) due to it's conflict with auto-cpufreq.service. However, this doesn't happen with AUR installs, which can lead to problems (e.g., [#463](https://github.com/AdnanHodzic/auto-cpufreq/issues/463)) if not masked manually.
- Open a terminal and run `sudo systemctl mask power-profiles-daemon.service` (then `enable` and `start` the auto-cpufreq.service if you haven't already).
- The TuneD daemon(enabled by default with Fedora 41) is [automatically disabled by auto-cpufreq-installer](https://github.com/AdnanHodzic/auto-cpufreq#1-power_helperpy-script-snap-package-install-only) due to it's conflict with auto-cpufreq.service.

### Gentoo Linux (GURU Repository)

Expand Down
2 changes: 2 additions & 0 deletions auto_cpufreq/bin/auto_cpufreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def config_info_dialog():
else:
gnome_power_detect_install()
gnome_power_stop_live()
tuned_stop_live()
tlp_service_detect()
while True:
try:
Expand All @@ -107,6 +108,7 @@ def config_info_dialog():
countdown(2)
except KeyboardInterrupt:
gnome_power_start_live()
tuned_start_live()
print()
break
conf.notifier.stop()
Expand Down
4 changes: 4 additions & 0 deletions auto_cpufreq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ def deploy_daemon():
gnome_power_detect_install()
gnome_power_svc_disable()

tuned_svc_disable()

tlp_service_detect() # output warning if TLP service is detected

call("/usr/local/bin/auto-cpufreq-install", shell=True)
Expand Down Expand Up @@ -372,6 +374,8 @@ def remove_daemon():
gnome_power_rm_reminder()
gnome_power_svc_enable()

tuned_svc_enable()

# run auto-cpufreq daemon remove script
call("/usr/local/bin/auto-cpufreq-remove", shell=True)

Expand Down
35 changes: 35 additions & 0 deletions auto_cpufreq/power_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def does_command_exists(cmd): return which(cmd) is not None
powerprofilesctl_exists = does_command_exists("powerprofilesctl")
systemctl_exists = does_command_exists("systemctl")
tlp_stat_exists = does_command_exists("tlp-stat")
tuned_stat_exists = does_command_exists("tuned")

# detect if gnome power profile service is running
if not IS_INSTALLED_WITH_SNAP:
Expand Down Expand Up @@ -99,10 +100,18 @@ def gnome_power_stop_live():
call(["powerprofilesctl", "set", "balanced"])
call(["systemctl", "stop", "power-profiles-daemon"])

# stops tuned (live)
def tuned_stop_live():
if systemctl_exists and tuned_stat_exists:
call(["systemctl", "stop", "tuned"])

# starts gnome >= 40 power profiles (live)
def gnome_power_start_live():
if systemctl_exists: call(["systemctl", "start", "power-profiles-daemon"])

def tuned_start_live():
if systemctl_exists: call(["systemctl", "start", "tuned"])

# enable gnome >= 40 power profiles (uninstall)
def gnome_power_svc_enable():
if systemctl_exists:
Expand All @@ -117,6 +126,17 @@ def gnome_power_svc_enable():
print("If this causes any problems, please submit an issue:")
print(GITHUB+"/issues")

def tuned_svc_enable():
if systemctl_exists:
try:
print("* Enabling TuneD\n")
call(["systemctl", "unmask", "tuned"])
call(["systemctl", "enable", "--now", "tuned"])
except:
print("\nUnable to enable GNOME power profiles")
print("If this causes any problems, please submit an issue:")
print(GITHUB+"/issues")

# gnome power profiles current status
def gnome_power_svc_status():
if systemctl_exists:
Expand Down Expand Up @@ -209,6 +229,17 @@ def disable_power_profiles_daemon():
print("If this causes any problems, please submit an issue:")
print(GITHUB+"/issues")

def disable_tuned_daemon():
# always disable TuneD daemon
try:
print("\n* Disabling TuneD daemon")
call(["systemctl", "disable", "--now", "tuned"])
call(["systemctl", "mask", "tuned"])
except:
print("\nUnable to disable TuneD daemon")
print("If this causes any problems, please submit an issue:")
print(GITHUB+"/issues")

# default gnome_power_svc_disable func (balanced)
def gnome_power_svc_disable():
snap_pkg_check = 0
Expand Down Expand Up @@ -245,6 +276,10 @@ def gnome_power_svc_disable():

disable_power_profiles_daemon()

def tuned_svc_disable():
if systemctl_exists and tuned_stat_exists:
disable_tuned_daemon()

# cli
@click.command()
#@click.option("--gnome_power_disable", help="Disable GNOME Power profiles service (default: balanced), reference:\n https://bit.ly/3bjVZW1", type=click.Choice(['balanced', 'performance'], case_sensitive=False))
Expand Down

0 comments on commit 6a13948

Please sign in to comment.