This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / tools / power-profile / power-profile.sh
1.8 kB 87 lines
1#!/usr/bin/env bash 2 3set -euo pipefail 4 5# Power profiles in watts (stapm/sustained limit) 6PROFILE_LOW=3 7PROFILE_NORMAL=15 8PROFILE_HIGH=28 9 10# State file for eww integration (ryzenadj -i doesn't work on all CPUs) 11STATE_FILE="/tmp/power-profile-state" 12 13usage() { 14 cat <<EOF 15Usage: power-profile <profile|watts> 16 17Profiles: 18 low - ${PROFILE_LOW}W TDP (battery saving) 19 normal - ${PROFILE_NORMAL}W TDP (balanced) 20 high - ${PROFILE_HIGH}W TDP (performance) 21 22Or specify watts directly: 23 power-profile 10 # Set 10W TDP 24 25Burst limits are automatically calculated: 26 slow = stapm × 1.2 27 fast = stapm × 1.5 28 29Examples: 30 power-profile low 31 power-profile normal 32 power-profile high 33 power-profile 5 34EOF 35} 36 37set_tdp() { 38 local name=$1 39 local stapm=$2 40 # Calculate burst limits (using integer math, *10 then /10 to simulate decimals) 41 local slow=$(( (stapm * 12) / 10 )) 42 local fast=$(( (stapm * 15) / 10 )) 43 44 local stapm_mw=$((stapm * 1000)) 45 local slow_mw=$((slow * 1000)) 46 local fast_mw=$((fast * 1000)) 47 48 echo "Setting power profile:" 49 echo " STAPM (sustained): ${stapm}W" 50 echo " Slow limit: ${slow}W" 51 echo " Fast limit: ${fast}W" 52 /run/wrappers/bin/sudo /run/current-system/sw/bin/ryzenadj --stapm-limit="$stapm_mw" --slow-limit="$slow_mw" --fast-limit="$fast_mw" 53 54 # Write state for eww integration 55 echo "$name $stapm" > "$STATE_FILE" 56 echo "Done." 57} 58 59if [[ $# -ne 1 ]]; then 60 usage 61 exit 1 62fi 63 64case "$1" in 65 low) 66 set_tdp "low" "$PROFILE_LOW" 67 ;; 68 normal) 69 set_tdp "normal" "$PROFILE_NORMAL" 70 ;; 71 high) 72 set_tdp "high" "$PROFILE_HIGH" 73 ;; 74 -h|--help|help) 75 usage 76 exit 0 77 ;; 78 *) 79 if [[ "$1" =~ ^[0-9]+$ ]]; then 80 set_tdp "custom" "$1" 81 else 82 echo "Error: Unknown profile '$1'" 83 usage 84 exit 1 85 fi 86 ;; 87esac