Merge pull request #2 from narukeh/patch-1

Much cleaner
This commit is contained in:
krisdoodle45 2022-03-14 21:18:59 +01:00 committed by GitHub
commit b3e999af07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,12 +31,9 @@ for battery in /sys/class/power_supply/BAT?*; do
*) exit 1 ;;
esac
capacity="$(cat "$battery/capacity" 2>&1)"
if [ "$status" = "🔋" ]; then
# Changes the icon if lower than 50% and discharging
[ "$capacity" -le 50 ] && status="🪫"
# Will make a warn variable if discharging and very low
[ "$capacity" -le 25 ] && warn="❗"
fi
test $status = '🔋' && \
test $capacity -le 50 && stat='🪫' && \
test $capacity -le 25 && warn='❗'
# Prints the info
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
done && printf "\\n"