From 2913a7c622c41c37019958403d38c7acabd1f173 Mon Sep 17 00:00:00 2001 From: Riyyi Date: Mon, 15 Jan 2018 16:24:28 +0100 Subject: [PATCH] Add battery i3block script --- .scripts/wm/battery.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 .scripts/wm/battery.sh diff --git a/.scripts/wm/battery.sh b/.scripts/wm/battery.sh new file mode 100755 index 0000000..c648eb3 --- /dev/null +++ b/.scripts/wm/battery.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +BAT_NUMBER=${BLOCK_INSTANCE:-"0"} +BAT_INFO="$(acpi -b | grep Battery\ $BAT_NUMBER:)" + +CAPACITY=$(echo $BAT_INFO | awk '{ print int($4) }') +TIME="$(echo $BAT_INFO | awk '{ print substr($5, 0, length($5) - 3) }')" + +if [ "$(echo $BAT_INFO | awk '{ print $6 }')" = "remaining" ]; then + if [ "$CAPACITY" -ge "80" ]; then + ICON="" + elif [ "$CAPACITY" -ge "60" ]; then + ICON="" + elif [ "$CAPACITY" -ge "40" ]; then + ICON="" + elif [ "$CAPACITY" -ge "20" ]; then + ICON="" + else + ICON="" + fi +else + ICON="" +fi + +echo "$ICON $CAPACITY% ($TIME)" +echo "$ICON $CAPACITY%" +echo "#FFFFFF"