File tree 3 files changed +10
-4
lines changed
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"
7
7
print_battery_percentage () {
8
8
# percentage displayed in the 2nd field of the 2nd row
9
9
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 "
11
13
elif command_exists " pmset" ; then
12
14
pmset -g batt | grep -o " [0-9]\{1,3\}%"
13
15
elif command_exists " acpi" ; then
Original file line number Diff line number Diff line change @@ -110,7 +110,9 @@ acpi_battery_remaining_time() {
110
110
}
111
111
112
112
print_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
114
116
pmset_battery_remaining_time
115
117
elif command_exists " acpi" ; then
116
118
acpi_battery_remaining_time
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ is_chrome() {
24
24
25
25
is_wsl () {
26
26
version=$( < /proc/version)
27
- if [[ " $version " == * " Microsoft" * ]]; then
27
+ if [[ " $version " == * " Microsoft" * || " $version " == * " microsoft " * ]]; then
28
28
return 0
29
29
else
30
30
return 1
@@ -38,7 +38,9 @@ command_exists() {
38
38
39
39
battery_status () {
40
40
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 "
42
44
elif command_exists " pmset" ; then
43
45
pmset -g batt | awk -F ' ; *' ' NR==2 { print $2 }'
44
46
elif command_exists " acpi" ; then
You can’t perform that action at this time.
0 commit comments