Use the new 🪫 emoji in sb-battery

When the battery goes below 50%, the icon now changes to this one
This commit is contained in:
krisdoodle45 2022-02-17 18:18:59 +01:00 committed by GitHub
parent 82b70e3a8e
commit 3b71a182d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ case $BLOCK_BUTTON in
♻: stagnant charge ♻: stagnant charge
🔌: charging 🔌: charging
⚡: charged ⚡: charged
🪫: less than 50% remaining
❗: battery very low! ❗: battery very low!
- Scroll to change adjust xbacklight." ;; - Scroll to change adjust xbacklight." ;;
4) xbacklight -inc 10 ;; 4) xbacklight -inc 10 ;;
@ -30,8 +31,12 @@ for battery in /sys/class/power_supply/BAT?*; do
*) exit 1 ;; *) exit 1 ;;
esac esac
capacity="$(cat "$battery/capacity" 2>&1)" capacity="$(cat "$battery/capacity" 2>&1)"
# Will make a warn variable if discharging and low if [ "$status" = "🔋" ]; then
[ "$status" = "🔋" ] && [ "$capacity" -le 25 ] && warn="❗" # 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
# Prints the info # Prints the info
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
done && printf "\\n" done && printf "\\n"