File tree 2 files changed +10
-2
lines changed
2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ source "$CURRENT_DIR/helpers.sh"
6
6
7
7
print_battery_percentage () {
8
8
# percentage displayed in the 2nd field of the 2nd row
9
- if is_wsl; then
9
+ if is_termux; then
10
+ termux-battery-status | jq -er ' "\(.percentage)%"'
11
+ elif is_wsl; then
10
12
local battery
11
13
battery=$( find /sys/class/power_supply/* /capacity | tail -n1)
12
14
cat " $battery "
Original file line number Diff line number Diff line change @@ -31,13 +31,19 @@ is_wsl() {
31
31
fi
32
32
}
33
33
34
+ is_termux () {
35
+ [[ $( uname -o) == " Android" ]] && command -v termux-info > /dev/null 2>&1
36
+ }
37
+
34
38
command_exists () {
35
39
local command=" $1 "
36
40
type " $command " > /dev/null 2>&1
37
41
}
38
42
39
43
battery_status () {
40
- if is_wsl; then
44
+ if is_termux; then
45
+ termux-battery-status | jq -er ' .status | ascii_downcase'
46
+ elif is_wsl; then
41
47
local battery
42
48
battery=$( find /sys/class/power_supply/* /status | tail -n1)
43
49
awk ' {print tolower($0);}' " $battery "
You can’t perform that action at this time.
0 commit comments