Add different icon types

This commit is contained in:
flyingscorpio@clevo 2022-02-28 17:00:38 +01:00
parent da6903889c
commit 2364480b49

View file

@ -1,14 +1,28 @@
#!/bin/bash
icon=""
battery_full=$(echo -e "\uf240")
battery_75=$(echo -e "\uf241")
battery_50=$(echo -e "\uf242")
battery_25=$(echo -e "\uf243")
battery_empty=$(echo -e "\uf244")
#battery_charging=$(echo -e "\u")
percent="$(upower -d | awk '/percentage/ {print $2}' | head -n 1)"
icon="${battery_full}"
percent="$(upower -d | awk '/percentage/ {print $2}' | head -n 1 | cut -d% -f1)"
remaining="$(upower -d | awk -F: '/time to empty/ {print $2}' | awk '{print $1,$2}' | head -n 1)"
if upower -d | grep '\bcharging\b' >/dev/null 2>&1; then
echo "${icon} ${percent}"
icon=${battery_charging}
echo "${icon} ${percent}%"
elif upower -d | grep '\bdischarging\b' >/dev/null 2>&1; then
if [ -n "$remaining" ] && [ "$(echo "$percent" | awk -F% '{print $1}')" -lt "$THRESHOLD" ]; then
if [ "$percent" -lt 25 ]; then
icon="${battery_25}"
elif [ "$percent" -lt 50 ]; then
icon="${battery_50}"
elif [ "$percent" -lt 75 ]; then
icon="${battery_75}"
if [ "$percent" -lt "$THRESHOLD" ]; then
notify-send "CHARGE BATTERY"
for file in /dev/pts/*; do
if [ "$(ls -l "$file" | awk '{print $5}')" = '136,' ]; then
@ -16,7 +30,7 @@ elif upower -d | grep '\bdischarging\b' >/dev/null 2>&1; then
fi
done
fi
echo "${icon} ${percent} (${remaining})"
echo "${icon} ${percent}% (${remaining})"
else
echo ""
fi