diff --git a/bin/omarchy-powerprofiles-list b/bin/omarchy-powerprofiles-list index 73a3d28f..a00caa72 100755 --- a/bin/omarchy-powerprofiles-list +++ b/bin/omarchy-powerprofiles-list @@ -8,12 +8,10 @@ if [[ ${1:-} != "" && ${1:-} != "--active-state" ]]; then exit 1 fi -if [[ ${1:-} == "--active-state" ]]; then - powerprofilesctl list 2>/dev/null | - awk '/^\s*[* ]\s*[a-zA-Z0-9-]+:$/ { active=($1=="*"); gsub(/^[*[:space:]]+|:$/,""); print $0 "\t" (active ? 1 : 0) }' | - tac -else - powerprofilesctl list 2>/dev/null | - awk '/^\s*[* ]\s*[a-zA-Z0-9-]+:$/ { gsub(/^[*[:space:]]+|:$/,""); print }' | - tac -fi +powerprofilesctl list 2>/dev/null | + awk -v with_state="${1:+1}" '/^\s*[* ]\s*[a-zA-Z0-9-]+:$/ { + active = ($1 == "*") ? 1 : 0 + gsub(/^[*[:space:]]+|:$/, "") + print $0 (with_state ? "\t" active : "") + }' | + tac diff --git a/bin/omarchy-powerprofiles-set b/bin/omarchy-powerprofiles-set index 54872140..1135e4d5 100755 --- a/bin/omarchy-powerprofiles-set +++ b/bin/omarchy-powerprofiles-set @@ -27,7 +27,7 @@ case "$action" in *) usage ;; esac -mapfile -t profiles < <(powerprofilesctl list | awk '/^\s*[* ]\s*[a-zA-Z0-9\-]+:$/ { gsub(/^[*[:space:]]+|:$/,""); print }') +mapfile -t profiles < <(omarchy-powerprofiles-list) profile_available() { [[ " ${profiles[*]} " == *" $1 "* ]]