aboutsummaryrefslogtreecommitdiff
path: root/i3blocks
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2019-04-16 12:27:11 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2019-04-16 12:27:11 +0200
commit6844394d4e77bf13b7662c8129cb6b37fbbdd56f (patch)
treeb7d3e9a04a8b6c35a39288cc5dda3e5d2d18231d /i3blocks
parent8a8c0547788cf54beb0ce70fe866dae15cb3a06c (diff)
downloadscripts-6844394d4e77bf13b7662c8129cb6b37fbbdd56f.tar.gz
scripts-6844394d4e77bf13b7662c8129cb6b37fbbdd56f.zip
i3battery.sh now sends a notification when battery is too low.
Diffstat (limited to 'i3blocks')
-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 ""