summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Noll <nnoll523@gmail.com>2020-06-20 17:09:26 -0700
committerNicholas Noll <nnoll523@gmail.com>2020-06-20 17:09:26 -0700
commit31d9cb5cfaa17b09f0b3a746cbedb46301a35ed8 (patch)
tree39a02a8c795e00ca129695724133dc432f6b8c22
parent24c19852baba32215d24297dc30804af91b72cee (diff)
added battery indicator
-rw-r--r--.xinitrc20
1 files changed, 19 insertions, 1 deletions
diff --git a/.xinitrc b/.xinitrc
index 5d986e3..a7314f3 100644
--- a/.xinitrc
+++ b/.xinitrc
@@ -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 &