Add community scripts for i3blocks

This commit is contained in:
2020-02-19 15:55:35 +00:00
parent 3233439d88
commit 3236629420
19 changed files with 746 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
################################
# Shows info about connected batteries.
#
# Dependencies:
# - acpi
#
# @return {Number(%)}: Current battery charge
################################
dir=$(dirname $0)
source $dir/util.sh
full=""
short=""
status=0
# Exit if no battery was found
if [ "$(acpi)" == "" ]; then exit 0; fi
state=$(acpi | sed -n 's/Battery [0-9]: \([A-Z]\).*, .*/\1/p')
chg=$(acpi | sed -n 's/Battery [0-9]:.*, \([0-9]\{1,3\}\)%.*/\1/p')
# Charging or Unknown
if [ $state = "C" ] || [ $state = "U" ]; then
icon=""
else
if [ $chg -le 10 ]; then
icon=""
status=33
else
icon=""
fi
fi
full="$icon $chg%"
short="$chg%"
echo $full
echo $short
exit $status