#!/usr/bin/bash
# ABOUTME: Waybar module showing battery conservation mode status.
# ABOUTME: Outputs heart icon when active (threshold ≤80), empty when inactive.

THRESHOLD_FILE="/sys/class/power_supply/BAT0/charge_control_end_threshold"

# No battery threshold support → no output → Waybar hides module
[[ -f "$THRESHOLD_FILE" ]] || exit 0

THRESHOLD=$(cat "$THRESHOLD_FILE")

if [[ "$THRESHOLD" -le 80 ]]; then
    jq --compact-output -n \
        --arg text "♥" \
        --arg tooltip "Battery Conservation: ON (limit ${THRESHOLD}%)" \
        --arg class "on" \
        '{text: $text, tooltip: $tooltip, class: $class}'
fi
# Threshold > 80 → no output → Waybar hides module
