Skip to content

Commit 2b17cdd

Browse files
committed
Add termux support
ref: tmux-plugins#114
1 parent 44d4689 commit 2b17cdd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

scripts/battery_percentage.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ source "$CURRENT_DIR/helpers.sh"
66

77
print_battery_percentage() {
88
# 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
1012
local battery
1113
battery=$(find /sys/class/power_supply/*/capacity | tail -n1)
1214
cat "$battery"

scripts/helpers.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ is_wsl() {
3131
fi
3232
}
3333

34+
is_termux() {
35+
[[ $(uname -o) == "Android" ]] && command -v termux-info >/dev/null 2>&1
36+
}
37+
3438
command_exists() {
3539
local command="$1"
3640
type "$command" >/dev/null 2>&1
3741
}
3842

3943
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
4147
local battery
4248
battery=$(find /sys/class/power_supply/*/status | tail -n1)
4349
awk '{print tolower($0);}' "$battery"

0 commit comments

Comments
 (0)