PinePhoneBoyOS/usr/local/bin/waybar_battery

16 lines
317 B
Plaintext
Raw Permalink Normal View History

#!/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\"}