16 lines
317 B
Bash
16 lines
317 B
Bash
#!/bin/bash
|
|
|
|
READBAT="cat /sys/class/power_supply/axp20x-battery/uevent"
|
|
GETVAL="cut -d= -f2"
|
|
LOWERCASE="tr '[:upper:]' '[:lower:]'"
|
|
|
|
STATUS=`$READBAT | grep STATUS | $GETVAL | $LOWERCASE`
|
|
CHARGE=`$READBAT | grep CAPACITY | $GETVAL`
|
|
|
|
TEXT="$CHARGE%"
|
|
CLASS=$STATUS
|
|
|
|
|
|
echo {\"text\": \"$TEXT\", \"class\": \"$CLASS\"}
|
|
|