diff --git a/MANUAL.md b/MANUAL.md index 00a78669..7e16ac72 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -71,7 +71,15 @@ These options are not written to the config file as they are stored in efivars. ### Profiles -asusctl can support setting a power profile via platform_profile drivers. This requires [power-profiles-daemon](https://gitlab.freedesktop.org/hadess/power-profiles-daemon) v0.10.0 minimum. It also requires the kernel patch for platform_profile support to be applied form [here](https://lkml.org/lkml/2021/8/18/1022) - this patch is merged to 5.15 kernel upstream. +asusctl supports setting power profiles via ACPI `platform_profile` drivers. + +> [!IMPORTANT] +> **Compatibility with `power-profiles-daemon`**: +> Do **NOT** run `power-profiles-daemon` alongside `asusd`. Running both services concurrently causes race conditions and contention over `/sys/firmware/acpi/platform_profile` and CPU EPP preferences. +> +> To allow `asusd` to manage platform profiles, EPP, custom fan curves, and PPT limits cleanly, disable `power-profiles-daemon`: +> ```bash +> sudo systemctl disable --now power-profiles-daemon.service A common use of asusctl is to bind the `fn+f5` (fan) key to `asusctl profile -n` to cycle through the 3 profiles: diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index d4cbef1b..cf87bd35 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -804,6 +804,18 @@ fn handle_throttle_profile( } let proxy = PlatformProxyBlocking::new(conn)?; + + if let Ok(dbus_proxy) = zbus::blocking::fdo::DBusProxy::new(conn) { + if let Ok(ppd_name) = zbus::names::BusName::try_from("net.hadess.PowerProfiles") { + if dbus_proxy.name_has_owner(ppd_name).unwrap_or(false) { + eprintln!("WARN: 'power-profiles-daemon' is running concurrently with asusd!"); + eprintln!("This causes EPP and platform_profile contention."); + eprintln!( + "Disable it via: 'sudo systemctl disable --now power-profiles-daemon.service'" + ); + } + } + } let current = proxy.platform_profile()?; let choices = proxy.platform_profile_choices()?; diff --git a/asusd/src/daemon.rs b/asusd/src/daemon.rs index 02f4025a..48d63b33 100644 --- a/asusd/src/daemon.rs +++ b/asusd/src/daemon.rs @@ -162,6 +162,30 @@ async fn start_daemon() -> Result<(), Box> { Err(e) => error!("XG Mobile LED: {e}"), } + // Check if power-profiles-daemon is running + if let Ok(dbus_proxy) = zbus::fdo::DBusProxy::new(&server).await { + let ppd_name = zbus::names::BusName::try_from("net.hadess.PowerProfiles"); + let ppd_owned = match ppd_name { + Ok(ref name) => dbus_proxy + .name_has_owner(name.clone()) + .await + .unwrap_or(false), + Err(_) => false, + }; + + if ppd_owned { + warn!( + "********************************************************************************" + ); + warn!("WARN: 'power-profiles-daemon' (or another PPD provider) is active on system D-Bus!"); + warn!("Running power-profiles-daemon concurrently with asusd causes EPP and platform_profile contention."); + warn!("To allow asusd to manage profiles, EPP, fan curves, and KDE/GNOME sliders natively, disable it via:"); + warn!(" sudo systemctl disable --now power-profiles-daemon.service"); + warn!( + "********************************************************************************" + ); + } + } // Request dbus name after finishing initalizing all functions server.request_name(DBUS_NAME).await?; diff --git a/distro-packaging/asusctl.install b/distro-packaging/asusctl.install index 312c6003..ddbcdc36 100644 --- a/distro-packaging/asusctl.install +++ b/distro-packaging/asusctl.install @@ -1,5 +1,76 @@ #!/hint/bash post_upgrade() { + local missing=0 + if [[ $2 == 3* ]]; then + echo -e "\033[0;34m" + echo "-> Upgrading from asusctl 3.X.X" + + if [[ -f "/etc/asusd/asusd.conf" ]]; then + echo -e "\033[0;33m" + echo "-> Old config found" + echo "-> Because of breaking changes your config will be moved too /etc/asusd/asusd.conf.old.3.X.X" + mv /etc/asusd/asusd.conf /etc/asusd/asusd.conf.old.3.X.X + echo -e "\033[0m" + fi + + echo -e "\033[0m" + fi; + + # test for features every upgrade, not just major 3.x -> 4.x + + platform_profile_choices=$(cat /sys/firmware/acpi/platform_profile_choices) + + if [[ $platform_profile_choices != "quiet balanced performance" ]]; then + if [[ $platform_profile_choices != "low-power balanced performance" ]]; then + echo -e "\033[0;31m" + echo "-> Platform profile support not found in current running kernel" + echo "-> Make sure you are using a kernel with patch: https://lore.kernel.org/lkml/20210818190731.19170-1-luke@ljones.dev/" + echo "-> and asus_wmi driver is loaded" + echo -e "\033[0m" + missing=1 + fi + fi + + # FIXME: test for fan control support here + + if false; then # FIXME + echo -e "\033[0;31m" + echo "-> Fan control support not found in current running kernel" + echo "-> Make sure you are using a kernel with patch: https://lore.kernel.org/lkml/20211024033705.5595-1-luke@ljones.dev/" + echo "-> and asus_wmi driver is loaded" + echo -e "\033[0m" + missing=1 + + fi + + if (( missing != 0 )); then + echo -e "\033[0;31m" + echo "==> Missing kernel support detected: the linux-g14 kernel includes support for all features." + echo -e "\033[0m" + fi + + if [ -d '/etc/mkinitcpio.conf.d' ]; then + if [ ! -f "/etc/mkinitcpio.conf.d/asus.conf" ]; then + echo -e "\033[0;33m" + echo "-> Adding asus modules to mkinitcpio.conf" + echo "MODULES+=(hid_asus asus_wmi asus_nb_wmi)" > /etc/mkinitcpio.conf.d/asus.conf + for f in /etc/mkinitcpio.d/*; do + all_config_fixed=$(cat $f | grep "#ALL_config" | wc -l) + default_config_fixed=$(cat $f | grep "#default_config" | wc -l) + if [[ $all_config_fixed == 0 ]]; then + sed -i 's/^ALL_config/#&/' $f + fi + if [[ $default_config_fixed == 0 ]]; then + sed -i 's/^default_config/#&/' $f + fi + + mkinitcpio -p $(basename -s .preset $f) + done + echo -e "\033[0m" + fi + fi + + # we might have missed this in a prior upgrade from 3.x cleanup_asusd_leftovers systemctl restart asusd.service } diff --git a/rog-control-center/src/main.rs b/rog-control-center/src/main.rs index b4f11946..d174799d 100644 --- a/rog-control-center/src/main.rs +++ b/rog-control-center/src/main.rs @@ -92,6 +92,19 @@ async fn main() -> Result<()> { // return Ok(()); } + if let Ok(dbus_proxy) = zbus::blocking::fdo::DBusProxy::new(&zbus_con) { + if let Ok(ppd_name) = zbus::names::BusName::try_from("net.hadess.PowerProfiles") { + if dbus_proxy.name_has_owner(ppd_name).unwrap_or(false) { + warn!("********************************************************************************"); + warn!("WARN: 'power-profiles-daemon' is active on system D-Bus!"); + warn!("Running power-profiles-daemon concurrently causes EPP and platform_profile contention."); + warn!("To allow asusd to manage profiles, EPP, fan curves, and KDE/GNOME sliders natively, disable it:"); + warn!(" sudo systemctl disable --now power-profiles-daemon.service"); + warn!("********************************************************************************"); + } + } + } + // start tokio let rt = Runtime::new().expect("Unable to create Runtime"); // Enter the runtime so that `tokio::spawn` is available immediately.