- Bash was annoying me, time to fuck it up a bit.
- Wanted to see if bat was charging or not as well as capacity.
- Bored.
Code: Select all
#!/bin/bash
# bat.sh
# Queries /sys/class/power_supply/BATn/ things
# and makes it a pretty ascii output.
if [ -d /sys/class/power_supply/BAT0/ ]
then
DIR=/sys/class/power_supply/BAT0/
else
DIR=/sys/class/power_supply/BAT1
fi
CAP=$(cat $DIR/capacity)
STATE=$(cat $DIR/status)
# Charging or What??
if [[ $STATE == D* ]]
then ST="-"
else ST="+"
fi
if [[ $CAP == 100 ]]
then ST=""
fi
echo {$CAP$ST]
very handy piped to i3 bar thing.
Which - for my ref, looks like this:
Code: Select all
#!/bin/sh
# shell script to prepend i3status with more stuff
i3status | while :
do
read line
echo "$(mocp -Q %title) | $( ~/bin/./bat.sh) | $line" || exit 1
done
Code: Select all
{98+]