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

@ -14,15 +14,14 @@ FULL_ICON="" # Plugged in, but no longer charging (fully charged)
CRITICAL_ICON="" CRITICAL_ICON=""
CRITICAL_PERCENTAGE=15 CRITICAL_PERCENTAGE=15
if [ -z "$BATTERY" ]; then if [ -z "$BATTERY" ]; then
# shellcheck disable=SC2010 # 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 fi
if [ -z "$ADAPTER" ]; then if [ -z "$ADAPTER" ]; then
# shellcheck disable=SC2010 # 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 fi
get_bat_info() { get_bat_info() {
@ -52,7 +51,6 @@ status="$(get_bat_info status)"
# status="Not charging" # status="Not charging"
# status="Discharging" # status="Discharging"
full="false" full="false"
capacity_icon="$(pick_icon "$capacity" 0 100 "${CAPACITY_ICONS[@]}")" capacity_icon="$(pick_icon "$capacity" 0 100 "${CAPACITY_ICONS[@]}")"
@ -69,7 +67,6 @@ fi
[ "$capacity" -le "$CRITICAL_PERCENTAGE" ] && critical="true" || critical="false" [ "$capacity" -le "$CRITICAL_PERCENTAGE" ] && critical="true" || critical="false"
jq -n -c --monochrome-output \ jq -n -c --monochrome-output \
--arg percent "$capacity" \ --arg percent "$capacity" \
--arg plugged "$adp_connected" \ --arg plugged "$adp_connected" \