File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,9 @@ source "$CURRENT_DIR/helpers.sh"
66
77print_battery_percentage () {
88 # percentage displayed in the 2nd field of the 2nd row
9- if command_exists " pmset" ; then
9+ if is_wsl; then
10+ cat /sys/class/power_supply/battery/capacity
11+ elif command_exists " pmset" ; then
1012 pmset -g batt | grep -o " [0-9]\{1,3\}%"
1113 elif command_exists " acpi" ; then
1214 acpi -b | grep -m 1 -Eo " [0-9]+%"
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ battery_discharging() {
1717
1818battery_charged () {
1919 local status=" $( battery_status) "
20- [[ $status =~ (charged) ]]
20+ [[ $status =~ (charged) || $status =~ (full) ]]
2121}
2222
2323
Original file line number Diff line number Diff line change @@ -22,13 +22,24 @@ is_chrome() {
2222 fi
2323}
2424
25+ is_wsl () {
26+ version=$( < /proc/version)
27+ if [[ " $version " == * " Microsoft" * ]]; then
28+ return 0
29+ else
30+ return 1
31+ fi
32+ }
33+
2534command_exists () {
2635 local command=" $1 "
2736 type " $command " > /dev/null 2>&1
2837}
2938
3039battery_status () {
31- if command_exists " pmset" ; then
40+ if is_wsl; then
41+ cat /sys/class/power_supply/battery/status | awk ' {print tolower($0);}'
42+ elif command_exists " pmset" ; then
3243 pmset -g batt | awk -F ' ; *' ' NR==2 { print $2 }'
3344 elif command_exists " acpi" ; then
3445 acpi -b | awk ' {gsub(/,/, ""); print tolower($3); exit}'
You can’t perform that action at this time.
0 commit comments