Allow AC adapter naming in battery script

This commit is contained in:
ItsDrike 2023-12-31 12:40:55 +01:00
parent 40094c9628
commit 29583e07b7
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0

View file

@ -10,19 +10,18 @@ source "./scripts/include"
CAPACITY_ICONS=("󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹")
CHARGING_ICON=""
DISCHARGING_ICON=""
FULL_ICON="" # Plugged in, but no longer charging (fully charged)
FULL_ICON="" # Plugged in, but no longer charging (fully charged)
CRITICAL_ICON=""
CRITICAL_PERCENTAGE=15
if [ -z "$BATTERY" ]; then
# shellcheck disable=SC2010
BATTERY="$(ls -t /sys/class/power_supply | grep "BAT" | head -n 1)"
BATTERY="$(\ls -t /sys/class/power_supply | grep "BAT" | head -n 1)"
fi
if [ -z "$ADAPTER" ]; then
# shellcheck disable=SC2010
ADAPTER="$(ls -t /sys/class/power_supply | grep "ADP" | head -n 1)"
ADAPTER="$(\ls -t /sys/class/power_supply | grep -E "ADP|AC" | head -n 1)"
fi
get_bat_info() {
@ -52,7 +51,6 @@ status="$(get_bat_info status)"
# status="Not charging"
# status="Discharging"
full="false"
capacity_icon="$(pick_icon "$capacity" 0 100 "${CAPACITY_ICONS[@]}")"
@ -69,7 +67,6 @@ fi
[ "$capacity" -le "$CRITICAL_PERCENTAGE" ] && critical="true" || critical="false"
jq -n -c --monochrome-output \
--arg percent "$capacity" \
--arg plugged "$adp_connected" \