diff options
Diffstat (limited to 'scripts/scripts/bat')
-rwxr-xr-x | scripts/scripts/bat | 56 |
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 | |||
3 | red="\e[31m" | ||
4 | grn="\e[32m" | ||
5 | ylw="\e[33m" | ||
6 | cyn="\e[36m" | ||
7 | blu="\e[34m" | ||
8 | prp="\e[35m" | ||
9 | bprp="\e[35;1m" | ||
10 | rst="\e[0m" | ||
11 | |||
12 | icon="$( ~/scripts/get_xres color4 )" | ||
13 | fg="$( ~/scripts/get_xres color8 )" | ||
14 | |||
15 | bat_status="" | ||
16 | bat_status=$( cat /sys/class/power_supply/BAT0/capacity ) | ||
17 | charging_status=$( cat /sys/class/power_supply/BAT0/status ) | ||
18 | |||
19 | health() { | ||
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 | |||
31 | bat_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 | |||
43 | while getopts qi options | ||
44 | do | ||
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 | ||
56 | done | ||