From d132e0ec618991be6783024f34d91073742ef325 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 21 May 2026 11:39:55 +0200 Subject: [PATCH] Use power profile helper in panel --- bin/omarchy-powerprofiles-list | 18 +++++++++++++++--- shell/plugins/panels/Power.qml | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/omarchy-powerprofiles-list b/bin/omarchy-powerprofiles-list index 093f9c99..73a3d28f 100755 --- a/bin/omarchy-powerprofiles-list +++ b/bin/omarchy-powerprofiles-list @@ -1,7 +1,19 @@ #!/bin/bash # omarchy:summary=Returns a list of all the available power profiles on the system. +# omarchy:args=[--active-state] -powerprofilesctl list | - awk '/^\s*[* ]\s*[a-zA-Z0-9\-]+:$/ { gsub(/^[*[:space:]]+|:$/,""); print }' | - tac +if [[ ${1:-} != "" && ${1:-} != "--active-state" ]]; then + echo "Usage: omarchy-powerprofiles-list [--active-state]" >&2 + 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 diff --git a/shell/plugins/panels/Power.qml b/shell/plugins/panels/Power.qml index 2e7b2e16..ef2d27a8 100644 --- a/shell/plugins/panels/Power.qml +++ b/shell/plugins/panels/Power.qml @@ -122,7 +122,7 @@ Panel { Process { id: profilesProc - command: ["bash", "-lc", "powerprofilesctl list 2>/dev/null | awk '/^\\s*[* ]\\s*[a-zA-Z0-9-]+:$/ { active=($1==\"*\"); gsub(/^[*[:space:]]+|:$/,\"\"); print $0 \"\\t\" (active ? 1 : 0) }'"] + command: [root.bar ? root.bar.omarchyPath + "/bin/omarchy-powerprofiles-list" : "omarchy-powerprofiles-list", "--active-state"] stdout: StdioCollector { waitForEnd: true; onStreamFinished: root.updateProfiles(text) } }