Change battery labels

This commit is contained in:
flyingscorpio@clevo 2022-10-14 16:22:51 +02:00
parent ad6dcb29c2
commit bd39d8af10
2 changed files with 30 additions and 14 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash
icon="${LABEL_FULL}"
icon="${LABEL_100}"
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)"
@ -9,15 +9,25 @@ if upower -d | grep '\bcharging\b' >/dev/null 2>&1; then
icon="${LABEL_CHARGING}"
echo "${icon} ${percent}%"
elif upower -d | grep '\bdischarging\b' >/dev/null 2>&1; then
if [ "$percent" -lt 25 ]; then
icon="${LABEL_25}"
if [ "$percent" -lt 10 ]; then
icon="${LABEL_10}"
elif [ "$percent" -lt 20 ]; then
icon="${LABEL_20}"
elif [ "$percent" -lt 30 ]; then
icon="${LABEL_30}"
elif [ "$percent" -lt 40 ]; then
icon="${LABEL_40}"
elif [ "$percent" -lt 50 ]; then
icon="${LABEL_50}"
elif [ "$percent" -lt 75 ]; then
icon="${LABEL_75}"
elif [ "$percent" -lt 70 ]; then
icon="${LABEL_70}"
elif [ "$percent" -lt 80 ]; then
icon="${LABEL_80}"
elif [ "$percent" -lt 90 ]; then
icon="${LABEL_90}"
fi
if [ "$percent" -lt "$THRESHOLD" ]; then
icon="${LABEL_EMPTY}"
icon="${LABEL_ALERT}"
notify-send "CHARGE BATTERY"
for file in /dev/pts/*; do
if [ "$(ls -l "$file" | awk '{print $5}')" = '136,' ]; then
@ -25,7 +35,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 ""
echo "${icon}"
fi

View file

@ -66,12 +66,18 @@ LABEL_IP=<span foreground='#8ccaff'>ﯱ </span>
[battery]
THRESHOLD=10
LABEL_FULL=
LABEL_75=
LABEL_50=
LABEL_25=
LABEL_EMPTY=
LABEL_CHARGING=<span foreground='#8cff8a'> </span>
LABEL_100=
LABEL_90=
LABEL_80=
LABEL_70=
LABEL_60=
LABEL_50=
LABEL_40=
LABEL_30=
LABEL_20=
LABEL_10=
LABEL_ALERT=
LABEL_CHARGING=<span foreground='#8cff8a'></span>
interval=5
[calendar]