diff options
author | Nicholas Noll <nnoll523@gmail.com> | 2020-06-20 17:09:26 -0700 |
---|---|---|
committer | Nicholas Noll <nnoll523@gmail.com> | 2020-06-20 17:09:26 -0700 |
commit | 31d9cb5cfaa17b09f0b3a746cbedb46301a35ed8 (patch) | |
tree | 39a02a8c795e00ca129695724133dc432f6b8c22 | |
parent | 24c19852baba32215d24297dc30804af91b72cee (diff) |
added battery indicator
-rw-r--r-- | .xinitrc | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -16,6 +16,24 @@ mail() { fi } +battery() { + CHARGE=$(cat /sys/class/power_supply/BAT0/capacity) + STATUS=$(cat /sys/class/power_supply/BAT0/status) + if [ "$STATUS" = "Charging" ]; then + printf " %s%%" "$CHARGE" + else + if [ "$CHARGE" -le 30 ]; then + printf " %s%%" "$CHARGE" + elif [ "$CHARGE" -le 60 ]; then + printf " %s%%" "$CHARGE" + elif [ "$CHARGE" -le 90 ]; then + printf " %s%%" "$CHARGE" + else + printf " %s%%" "$CHARGE" + fi + fi +} + volume() { VOL=$(amixer get Master | tail -n1 | sed -r "s/.*\[(.*)%\].*/\1/") @@ -49,7 +67,7 @@ ipaddr() { while true do - xsetroot -name "$(volume)│$(memory)│$(ipaddr)│$(cpu)│$(mail)│$(datetime)" + xsetroot -name "$(volume)│$(battery)│$(memory)│$(ipaddr)│$(cpu)│$(mail)│$(datetime)" sleep 20s done & |