aboutsummaryrefslogtreecommitdiff
path: root/i3blocks/i3battery.sh
diff options
context:
space:
mode:
Diffstat (limited to 'i3blocks/i3battery.sh')
-rwxr-xr-xi3blocks/i3battery.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/i3blocks/i3battery.sh b/i3blocks/i3battery.sh
index d6acda6..b7441d1 100755
--- a/i3blocks/i3battery.sh
+++ b/i3blocks/i3battery.sh
@@ -11,8 +11,9 @@ case $BLOCK_BUTTON in
- Text color reflects charge left" ;;
esac
-capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
status=$(cat /sys/class/power_supply/"$1"/status)
+capacity=$(cat /sys/class/power_supply/"$1"/capacity) || exit
+remaining=$(acpi | cut -d' ' -f5 | cut -d':' -f-2)
if [ "$capacity" -ge 80 ]; then
color="#b8bb26"
@@ -24,14 +25,13 @@ elif [ "$capacity" -ge 10 ]; then
color="#fe8019"
else
color="#fb4934"
- [ "$status" != "Charging" ] && warn="❗"
+ [ "$status" != "Charging" ] && warn="❗" && dunstify -u critical -r "$(dunstifyIDs.sh "batteryLow")" "Battery remaining: $capacity% ($remaining)"
fi
[ -z "$warn" ] && warn=""
[ "$status" = "Charging" ] && color="#1fffaf"
-remaining=$(acpi | cut -d' ' -f5 | cut -d':' -f-2)
printf "<span color='%s'>%s%s%s (%s)</span>" "$color" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" "$remaining"
echo ""