Use labels for i3blocks battery
This commit is contained in:
parent
801dd6f74e
commit
ad6dcb29c2
2 changed files with 13 additions and 16 deletions
|
@ -1,32 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
GREEN="<span foreground='#8cff8a'>"
|
||||
NC="</span>"
|
||||
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 "${GREEN}\uf240${NC}")
|
||||
|
||||
icon="${battery_full}"
|
||||
icon="${LABEL_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
|
||||
icon="${battery_charging}"
|
||||
icon="${LABEL_CHARGING}"
|
||||
echo "${icon} ${percent}%"
|
||||
elif upower -d | grep '\bdischarging\b' >/dev/null 2>&1; then
|
||||
if [ "$percent" -lt 25 ]; then
|
||||
icon="${battery_25}"
|
||||
icon="${LABEL_25}"
|
||||
elif [ "$percent" -lt 50 ]; then
|
||||
icon="${battery_50}"
|
||||
icon="${LABEL_50}"
|
||||
elif [ "$percent" -lt 75 ]; then
|
||||
icon="${battery_75}"
|
||||
icon="${LABEL_75}"
|
||||
fi
|
||||
if [ "$percent" -lt "$THRESHOLD" ]; then
|
||||
icon="${battery_empty}"
|
||||
icon="${LABEL_EMPTY}"
|
||||
notify-send "CHARGE BATTERY"
|
||||
for file in /dev/pts/*; do
|
||||
if [ "$(ls -l "$file" | awk '{print $5}')" = '136,' ]; then
|
||||
|
@ -34,7 +25,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
|
||||
|
|
|
@ -66,6 +66,12 @@ 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>
|
||||
interval=5
|
||||
|
||||
[calendar]
|
||||
|
|
Loading…
Add table
Reference in a new issue