Overview and feature request (Recomendation for wayland users) #37
Replies: 3 comments
-
Below is a step-by-step English guide for someone unfamiliar with the system, showing how to automatically switch both Tuned and DAMX profiles on AC plug-in (“ac”) and unplug (“battery”) events. We use a small helper script, a systemd oneshot service, and udev rules to tie it all together. OverviewYou will install a shell script that:
We trigger this script via a systemd oneshot service (so long‐running commands work reliably) and fire that service from udev rules watching 1. Prerequisites
2. Helper ScriptCreate #!/usr/bin/env bash
# tuned-damx-power-cycle.sh
MODE="$1" # “ac” or “battery”
set -e
# Send profile command to DAMX daemon via its UNIX socket
damx_set() {
echo "{\"command\":\"set_thermal_profile\",\"params\":{\"profile\":\"$1\"}}" \
| socat - UNIX-CLIENT:/var/run/DAMX.sock >/dev/null 2>&1
}
case "$MODE" in
ac)
tuned-adm profile balanced
damx_set balanced
logger -t tuned-damx "[AC] Tuned→balanced, DAMX→balanced"
;;
battery)
tuned-adm profile laptop-battery-powersave
damx_set low_power
logger -t tuned-damx "[BATTERY] Tuned→laptop-battery-powersave, DAMX→quiet"
;;
*)
echo "Usage: $0 {ac|battery}"
exit 1
;;
esac Then make it root-owned and executable: sudo chown root:root /usr/local/bin/tuned-damx-power-cycle.sh
sudo chmod 755 /usr/local/bin/tuned-damx-power-cycle.sh
3. Systemd Oneshot ServiceCreate [Unit]
Description=Tuned & DAMX power switch (%i)
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/tuned-damx-power-cycle.sh %i
TimeoutSec=20
[Install]
WantedBy=multi-user.target
Reload systemd: sudo systemctl daemon-reload 4. Udev RulesCreate
Reload udev: sudo udevadm control --reload-rules 5. Testing
If everything works, your system will now automatically sync Tuned and DAMX profiles on power state changes. |
Beta Was this translation helpful? Give feedback.
-
also this is the script which i use for change profiles Click to view the script#!/bin/bash
# --- DAMX için fonksiyon ---
damx_set_profile() {
local PROFILE="$1"
# JSON komutunu sokete gönder
echo "{\"command\": \"set_thermal_profile\", \"params\": {\"profile\": \"$PROFILE\"}}" \
| socat - /var/run/DAMX.sock \
>/dev/null 2>&1
}
# --- Profil Listelerini Tanımla ---
# Tuned ve DAMX profilleri uyumlu olacak şekilde eşleştirdik
profiles_ac=(
"powersave"
"balanced"
"latency-performance" # Tuned profili
# throughput-performance # Opsiyonel
)
damx_profiles_ac=(
"quiet"
"balanced" # DAMX profili
"balanced-performance"
)
profiles_battery=(
"laptop-battery-powersave" # Tuned profili
"balanced-battery" # Tuned profili
)
damx_profiles_battery=(
"low-power"
"balanced"
)
target_battery_profile="laptop-battery-powersave" # Tuned event profili
target_damx_battery="low-power" # Batarya için DAMX default
# --- Argüman Kontrolü ---
ACTION="cycle"
if [[ "$1" == "--set-battery-default" ]]; then
ACTION="set_default"
fi
# --- Güç Kaynağını Tespit Et ---
current_profiles_list_name="profiles_battery"
current_damx_list_name="damx_profiles_battery"
active_power_source="Unknown"
ac_adapter=$(find /sys/class/power_supply/ -maxdepth 1 -name 'AC*' -print -quit)
if [[ -n "$ac_adapter" && -f "$ac_adapter/online" ]]; then
if [[ $(cat "$ac_adapter/online") -eq 1 ]]; then
current_profiles_list_name="profiles_ac"
current_damx_list_name="damx_profiles_ac"
active_power_source="AC"
else
current_profiles_list_name="profiles_battery"
current_damx_list_name="damx_profiles_battery"
active_power_source="Battery"
fi
else
exit 1
fi
# --- Eylemi Gerçekleştir ---
COMMAND_STATUS=1
next_profile=""
next_damx_profile=""
if [[ "$ACTION" == "set_default" && "$active_power_source" == "Battery" ]]; then
# Batarya event trigger: direkt hedef profile geç
next_profile="$target_battery_profile"
next_damx_profile="$target_damx_battery"
sudo tuned-adm profile "$next_profile"
COMMAND_STATUS=$?
damx_set_profile "$next_damx_profile"
else
# Normal cycle işlemi
# Tuned listesine bak
profiles_ref="${current_profiles_list_name}[@]"
tuned_list=("${!profiles_ref}")
damx_ref="${current_damx_list_name}[@]"
damx_list=("${!damx_ref}")
# Mevcut Tuned profili al
current_line=$(tuned-adm active)
current_profile=$(echo "$current_line" | sed -n "s/Current active profile: //p")
# Sonraki Tuned profili bul
idx=-1
for i in "${!tuned_list[@]}"; do
[[ "${tuned_list[$i]}" == "$current_profile" ]] && idx=$i && break
done
[[ $idx -lt 0 ]] && idx=0 || idx=$(( (idx + 1) % ${#tuned_list[@]} ))
next_profile="${tuned_list[$idx]}"
# Sonraki DAMX profili aynı index ile
next_damx_profile="${damx_list[$idx]:-${damx_list[0]}}"
# Profilleri uygula
sudo tuned-adm profile "$next_profile"
COMMAND_STATUS=$?
damx_set_profile "$next_damx_profile"
fi
# --- Bildirim (sadece manuel cycle) ---
if [[ "$ACTION" == "cycle" ]]; then
if [[ $COMMAND_STATUS -eq 0 ]]; then
notify-send "Güç Kaynağı: $active_power_source" \
"Tuned → $next_profile, DAMX → $next_damx_profile" \
-i preferences-system-power -u low
else
notify-send "Profil Değiştirme Hatası" \
"Tuned veya DAMX profili ayarlanamadı." -u critical
fi
fi
exit $COMMAND_STATUS |
Beta Was this translation helpful? Give feedback.
-
output_noaudio.mp4
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Save the following script as ultimate-power-manager.sh, make it executable with the command chmod +x ultimate-power-manager.sh, and launch it with the command sudo ./ultimate-power-manager.sh.
Click to view the script
BELOW THIS LINE IS MY OLDER CONFIGURATION BUT CHECK IT ALSO
The software runs as expected on wayland/hyprland Endeavour Os
But i realized a possible conflict with tuned power profiles, if i change tuned profile Max profile automatically sets to balanced, is there a way to change Max profile with terminal to be able to connect Max and tuned properly?
EDIT: I renamed my tuned profiles as simple names like balanced, performance and powersave; balanced and performance profile changes on tuned are now synced with DAM-Max, unable to activate Quiet profile automatically after setting tuned profile to powersave (DAM-Max profile disappears, no profile selected)...
Also if someone needed:
bind =, XF86Presentation, exec, DAM-FC-launcher # XF86Presentation is our nitro sense button, you can bind DAM-Max to it ;)
bind =$mainMod, XF86Presentation, exec, $UserScripts/cycle_tuned_profile.sh
Here is my DAM-FC-launcher for wayland:
If you want to use this without sudo password create a sudoers rule:
Beta Was this translation helpful? Give feedback.
All reactions