mirror of
https://github.com/tmux-plugins/tmux-battery.git
synced 2026-09-10 07:26:19 -04:00
Support print_battery_remain() for Linux/WSL (#119)
This commit is contained in:
parent
3a1a711ba1
commit
661aa4d25e
|
|
@ -116,7 +116,11 @@ acpi_battery_remaining_time() {
|
|||
|
||||
print_battery_remain() {
|
||||
if is_wsl; then
|
||||
echo "?" # currently unsupported on WSL
|
||||
local charge_full charge_now current_now
|
||||
charge_full=$(find /sys/class/power_supply/*/charge_full | tail -n1 | xargs cat)
|
||||
charge_now=$(find /sys/class/power_supply/*/charge_now | tail -n1 | xargs cat)
|
||||
current_now=$(find /sys/class/power_supply/*/current_now | tail -n1 | xargs cat)
|
||||
echo $charge_full $charge_now $current_now | awk '{num=($1-$2)/$3; printf "%02d:%02d:%02d", int(num), int(60*num%60), int(3600*num%60)}'
|
||||
elif command_exists "pmset"; then
|
||||
pmset_battery_remaining_time
|
||||
elif command_exists "acpi"; then
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ is_chrome() {
|
|||
|
||||
is_wsl() {
|
||||
version=$(</proc/version)
|
||||
if [[ "$version" == *"Microsoft"* || "$version" == *"microsoft"* ]]; then
|
||||
if [[ "$version" == *"Linux"* || "$version" == *"Microsoft"* || "$version" == *"microsoft"* ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
|
|
|
|||
Loading…
Reference in a new issue