#!/bin/sh # --- Gather Data --- # 1. Hyprland Version if [ -r "$HOME/.cache/hyprland-version" ]; then HYPR_VER="$(cat "$HOME/.cache/hyprland-version")" else HYPR_VER="hyprland" fi # 2. Power Profile if [ -r /sys/firmware/acpi/platform_profile ]; then PROFILE="$(cut -c1-3 /sys/firmware/acpi/platform_profile)" else PROFILE="unk" fi # 3. Load Average LOADAVG="$(cut -d' ' -f1 /proc/loadavg)" # 4. Battery if command -v upower >/dev/null 2>&1; then BAT_DEV="$(upower -e | grep BAT | head -n1)" if [ -n "$BAT_DEV" ]; then BAT_PCT="$(upower -i "$BAT_DEV" | awk '/percentage/ {print $2}')" BAT_STATE="$(upower -i "$BAT_DEV" | awk '/state/ {print $2}')" if [ -n "$BAT_PCT" ]; then case "$BAT_STATE" in charging) BAT="+$BAT_PCT" ;; discharging|fully-charged) BAT="$BAT_PCT" ;; *) BAT="?$BAT_PCT" ;; esac else BAT="?" fi else BAT="?" fi else BAT="?" fi # 5. Date DATE="$(date '+%Y-%m-%d %a %H:%M')" # --- Output to Yambar --- # We use the unicode vertical bar '│' (U+2502) to be safe from parsing errors. # We also append a newline explicitly. printf "hstatus|string| %s │ %s │ %s │ %s │ %s\n" \ "$HYPR_VER" "$PROFILE" "$LOADAVG" "$BAT" "$DATE" # FORCE FLUSH: This is likely why you saw {hstatus} before. # Some shells buffer printf. This ensures it sends immediately. echo ""