Extract shell panel status commands
This commit is contained in:
@@ -509,31 +509,7 @@ Panel {
|
||||
|
||||
Process {
|
||||
id: sinkAvailabilityProc
|
||||
command: ["bash", "-lc", `
|
||||
pactl list sinks 2>/dev/null | python3 -c '
|
||||
import re
|
||||
import sys
|
||||
|
||||
for block in re.split(r"(?m)^Sink #", sys.stdin.read())[1:]:
|
||||
name = re.search(r"(?m)^\\s*Name:\\s*(\\S+)", block)
|
||||
if not name:
|
||||
continue
|
||||
|
||||
ports = []
|
||||
in_ports = False
|
||||
for line in block.splitlines():
|
||||
if line.strip() == "Ports:":
|
||||
in_ports = True
|
||||
continue
|
||||
if in_ports and line.startswith("\\tActive Port:"):
|
||||
in_ports = False
|
||||
if in_ports and line.startswith("\\t\\t"):
|
||||
ports.append(line)
|
||||
|
||||
available = not ports or any("not available" not in port for port in ports)
|
||||
print("%s\\t%d" % (name.group(1), 1 if available else 0))
|
||||
'
|
||||
`]
|
||||
command: [root.bar ? root.bar.omarchyPath + "/bin/omarchy-audio-sink-availability" : "omarchy-audio-sink-availability"]
|
||||
stdout: StdioCollector {
|
||||
waitForEnd: true
|
||||
onStreamFinished: root.updateSinkAvailability(text)
|
||||
|
||||
@@ -286,7 +286,7 @@ Panel {
|
||||
|
||||
Process {
|
||||
id: stateProc
|
||||
command: ["bash", "-lc", "{ omarchy-brightness-display 2>/dev/null; echo; } | head -n 1; monitors_json=$(hyprctl monitors all -j); printf '%s\\n' \"$monitors_json\" | jq -r 'def internal: test(\"^(eDP|LVDS|DSI)-\"); ([.[] | select(.name | internal)][0].name // \"\"), ([.[] | select((.name | internal) | not)][0].name // \"\"), ([.[] | select((.name | internal) and .disabled != true)][0].name // \"\"), ([.[] | select((.name | internal) and .mirrorOf != \"none\")][0].mirrorOf // \"\")'; omarchy-hyprland-monitor-focused 2>/dev/null || echo; omarchy-hyprland-monitor-scaling 2>/dev/null || echo; printf '%s\\n' \"$monitors_json\" | jq -c '[.[] | {name, enabled:(.disabled != true), focused:(.focused == true)}]'"]
|
||||
command: [root.bar ? root.bar.omarchyPath + "/bin/omarchy-monitor-state" : "omarchy-monitor-state"]
|
||||
stdout: StdioCollector {
|
||||
waitForEnd: true
|
||||
onStreamFinished: {
|
||||
|
||||
@@ -116,25 +116,7 @@ Panel {
|
||||
|
||||
Process {
|
||||
id: batteryProc
|
||||
command: ["bash", "-lc", `
|
||||
bat=$(upower -e 2>/dev/null | grep BAT | head -n1)
|
||||
[[ -z $bat ]] && exit 0
|
||||
info=$(upower -i "$bat")
|
||||
printf 'percentage\t%s\n' "$(awk '/percentage/ { print int($2) "%"; exit }' <<<"$info")"
|
||||
printf 'state\t%s\n' "$(awk '/state/ { print $2; exit }' <<<"$info")"
|
||||
printf 'rate\t%s\n' "$(awk '/energy-rate/ { v=sprintf("%.1f", $2); sub(/\.0$/, "", v); print v "W"; exit }' <<<"$info")"
|
||||
printf 'size\t%s\n' "$(awk '/energy-full:/ { printf "%dWh", $2; exit }' <<<"$info")"
|
||||
printf 'time\t%s\n' "$($OMARCHY_PATH/bin/omarchy-battery-remaining-time 2>/dev/null)"
|
||||
end=$(cat /sys/class/power_supply/BAT*/charge_control_end_threshold 2>/dev/null | head -1)
|
||||
start=$(cat /sys/class/power_supply/BAT*/charge_control_start_threshold 2>/dev/null | head -1)
|
||||
if [[ -n $end ]]; then
|
||||
if [[ -n $start && $start != "$end" ]]; then
|
||||
printf 'threshold\t%s-%s%%\n' "$start" "$end"
|
||||
else
|
||||
printf 'threshold\t%s%%\n' "$end"
|
||||
fi
|
||||
fi
|
||||
`]
|
||||
command: [root.bar ? root.bar.omarchyPath + "/bin/omarchy-battery-status" : "omarchy-battery-status", "--shell"]
|
||||
stdout: StdioCollector { waitForEnd: true; onStreamFinished: root.updateKeyValue(text, "battery") }
|
||||
}
|
||||
|
||||
@@ -146,7 +128,7 @@ fi
|
||||
|
||||
Process {
|
||||
id: systemProc
|
||||
command: ["bash", "-lc", "cpu=$(top -bn1 | awk '/^%?Cpu/ { gsub(/,/, \"\"); for (i=1; i<=NF; i++) if ($(i+1) == \"id\") { printf \"%.0f%%\", 100 - $i; exit } }'); awk -v cpu=\"$cpu\" '/^MemTotal:/ { total=$2 } /^MemAvailable:/ { avail=$2 } END { used=total-avail; printf \"cpu\\t%s\\n\", cpu; printf \"memory\\t%.1fGB / %.0fGB\\n\", used/1024/1024, total/1024/1024 }' /proc/meminfo"]
|
||||
command: [root.bar ? root.bar.omarchyPath + "/bin/omarchy-system-stats" : "omarchy-system-stats"]
|
||||
stdout: StdioCollector { waitForEnd: true; onStreamFinished: root.updateKeyValue(text, "system") }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user