aboutsummaryrefslogtreecommitdiff
path: root/scripts/scripts/bat
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/scripts/bat')
-rwxr-xr-xscripts/scripts/bat56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/scripts/bat b/scripts/scripts/bat
new file mode 100755
index 0000000..6746d82
--- /dev/null
+++ b/scripts/scripts/bat
@@ -0,0 +1,56 @@
1#!/usr/bin/env bash
2
3red="\e[31m"
4grn="\e[32m"
5ylw="\e[33m"
6cyn="\e[36m"
7blu="\e[34m"
8prp="\e[35m"
9bprp="\e[35;1m"
10rst="\e[0m"
11
12icon="$( ~/scripts/get_xres color4 )"
13fg="$( ~/scripts/get_xres color8 )"
14
15bat_status=""
16bat_status=$( cat /sys/class/power_supply/BAT0/capacity )
17charging_status=$( cat /sys/class/power_supply/BAT0/status )
18
19health() {
20 for i in {0..4}
21 do
22 if [[ $i -le $(( $bat_status/20 )) ]]; then
23 echo -ne "#[fg=colour1]• "
24 else
25 echo -ne "#[fg=colour8]• "
26 fi
27 done
28 echo
29}
30
31bat_status_small() {
32 if [[ "$charging_status" = *Charging* ]]; then
33 echo -ne "+$bat_status%"
34 else
35 echo -ne "$bat_status%"
36 fi
37}
38
39[ -z "$1" ] && {
40 bat_status_small
41}
42
43while getopts qi options
44do
45 case $options in
46 i)
47 bat_status_small
48 ;;
49 q)
50 if [[ "$charging_status" = *Charging* ]]; then
51 echo -ne "+ $(health)"
52 else
53 health
54 fi
55 esac
56done