File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ source "$CURRENT_DIR/helpers.sh"
77print_battery_percentage () {
88 # percentage displayed in the 2nd field of the 2nd row
99 if is_wsl; then
10- cat /sys/class/power_supply/battery/capacity
10+ local battery
11+ battery=$( find /sys/class/power_supply/* /capacity | tail -n1)
12+ cat " $battery "
1113 elif command_exists " pmset" ; then
1214 pmset -g batt | grep -o " [0-9]\{1,3\}%"
1315 elif command_exists " acpi" ; then
Original file line number Diff line number Diff line change @@ -110,7 +110,9 @@ acpi_battery_remaining_time() {
110110}
111111
112112print_battery_remain () {
113- if command_exists " pmset" ; then
113+ if is_wsl; then
114+ echo " ?" # currently unsupported on WSL
115+ elif command_exists " pmset" ; then
114116 pmset_battery_remaining_time
115117 elif command_exists " acpi" ; then
116118 acpi_battery_remaining_time
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ is_chrome() {
2424
2525is_wsl () {
2626 version=$( < /proc/version)
27- if [[ " $version " == * " Microsoft" * ]]; then
27+ if [[ " $version " == * " Microsoft" * || " $version " == * " microsoft " * ]]; then
2828 return 0
2929 else
3030 return 1
@@ -38,7 +38,9 @@ command_exists() {
3838
3939battery_status () {
4040 if is_wsl; then
41- cat /sys/class/power_supply/battery/status | awk ' {print tolower($0);}'
41+ local battery
42+ battery=$( find /sys/class/power_supply/* /status | tail -n1)
43+ awk ' {print tolower($0);}' " $battery "
4244 elif command_exists " pmset" ; then
4345 pmset -g batt | awk -F ' ; *' ' NR==2 { print $2 }'
4446 elif command_exists " acpi" ; then
You can’t perform that action at this time.
0 commit comments