-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbatt.sh
More file actions
executable file
·44 lines (36 loc) · 738 Bytes
/
batt.sh
File metadata and controls
executable file
·44 lines (36 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# I found it somewhere on WWW
# Made some changes
# And use it on my Laptop
#
BATTERY='/proc/acpi/battery/BAT1'
NOW=$( awk '/^rema/ {print $3}' $BATTERY/state )
MAX=$( awk '/^design capacity:/ {print $3}' $BATTERY/info )
STATE=$( awk '/^charging state:/ {print $3}' $BATTERY/state )
PRC=$(( $NOW * 100 / $MAX ))
NONE='\033[00m'
BOLD='\033[01m'
RED='\033[01;31m'
GREEN='\033[01;32m'
YELLOW='\033[01;33m'
case "$STATE" in
'charged')
BATSTATE="$BOLD=$NONE"
;;
'charging')
BATSTATE="$BOLD+$NONE"
;;
'discharging')
BATSTATE="$BOLD-$NONE"
;;
esac
COLOR=$RED
if [ $PRC -gt "20" ]
then
COLOR=$YELLOW
fi
if [ $PRC -gt "50" ]
then
COLOR=$GREEN
fi
echo -e "${COLOR}${PRC}%${NONE} ${BATSTATE}"