This repository has no description
0

Configure Feed

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

tools.power-profile: add power profile management tool

Replaces the inline set_tdp script from aergia with a reusable tool
supporting low/normal/high presets and custom wattage with burst limits.

+94 -6
-6
machines/aergia/physical.nix
··· 52 52 53 53 environment.systemPackages = [ 54 54 pkgs.vulkan-tools 55 - (pkgs.writers.writeDashBin "set_tdp" '' 56 - set -efux 57 - watt=$1 58 - value=$(( $watt * 1000 )) 59 - ${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit="$value" --fast-limit="$value" --slow-limit="$value" 60 - '') 61 55 ]; 62 56 63 57 # corectrl
+14
tools/power-profile/flake-module.nix
··· 1 + { ... }: 2 + { 3 + perSystem = 4 + { pkgs, ... }: 5 + { 6 + packages.power-profile = pkgs.writeShellApplication { 7 + name = "power-profile"; 8 + runtimeInputs = [ 9 + pkgs.ryzenadj 10 + ]; 11 + text = builtins.readFile ./power-profile.sh; 12 + }; 13 + }; 14 + }
+80
tools/power-profile/power-profile.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + set -euo pipefail 4 + 5 + # Power profiles in watts (stapm/sustained limit) 6 + PROFILE_LOW=3 7 + PROFILE_NORMAL=15 8 + PROFILE_HIGH=28 9 + 10 + usage() { 11 + cat <<EOF 12 + Usage: power-profile <profile|watts> 13 + 14 + Profiles: 15 + low - ${PROFILE_LOW}W TDP (battery saving) 16 + normal - ${PROFILE_NORMAL}W TDP (balanced) 17 + high - ${PROFILE_HIGH}W TDP (performance) 18 + 19 + Or specify watts directly: 20 + power-profile 10 # Set 10W TDP 21 + 22 + Burst limits are automatically calculated: 23 + slow = stapm × 1.2 24 + fast = stapm × 1.5 25 + 26 + Examples: 27 + power-profile low 28 + power-profile normal 29 + power-profile high 30 + power-profile 5 31 + EOF 32 + } 33 + 34 + set_tdp() { 35 + local stapm=$1 36 + # Calculate burst limits (using integer math, *10 then /10 to simulate decimals) 37 + local slow=$(( (stapm * 12) / 10 )) 38 + local fast=$(( (stapm * 15) / 10 )) 39 + 40 + local stapm_mw=$((stapm * 1000)) 41 + local slow_mw=$((slow * 1000)) 42 + local fast_mw=$((fast * 1000)) 43 + 44 + echo "Setting power profile:" 45 + echo " STAPM (sustained): ${stapm}W" 46 + echo " Slow limit: ${slow}W" 47 + echo " Fast limit: ${fast}W" 48 + ryzenadj --stapm-limit="$stapm_mw" --slow-limit="$slow_mw" --fast-limit="$fast_mw" 49 + echo "Done." 50 + } 51 + 52 + if [[ $# -ne 1 ]]; then 53 + usage 54 + exit 1 55 + fi 56 + 57 + case "$1" in 58 + low) 59 + set_tdp "$PROFILE_LOW" 60 + ;; 61 + normal) 62 + set_tdp "$PROFILE_NORMAL" 63 + ;; 64 + high) 65 + set_tdp "$PROFILE_HIGH" 66 + ;; 67 + -h|--help|help) 68 + usage 69 + exit 0 70 + ;; 71 + *) 72 + if [[ "$1" =~ ^[0-9]+$ ]]; then 73 + set_tdp "$1" 74 + else 75 + echo "Error: Unknown profile '$1'" 76 + usage 77 + exit 1 78 + fi 79 + ;; 80 + esac