You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The reason it fails on Mac desktops via Mac laptops (MacBooks) is because desktops don't have batteries! Thus the value of $current_capacity is empty, so the multiplying an empty string by 100 fails.
The fix is to only enter the code block if $ioreg_output is not empty. I will submit a Pull Request that fixes this.
The text was updated successfully, but these errors were encountered:
Here is the pull request that fixes the issue: #75
I would be grateful if you would consider merging it in. Thank you!
errantepiphany
changed the title
battery slice fails on mac desktops
battery slice fails on mac desktops (fix provided!)
Feb 14, 2019
errantepiphany
changed the title
battery slice fails on mac desktops (fix provided!)
battery checking errors on mac desktops (fix provided!)
Feb 16, 2019
The second fix on this PR is the same chunk of code (battery checking). In the linux block, the original code simply iterates over "/sys/class/power_supply/BAT*" . However, the "/sys/class/power_supply" directory doesn't exist on some systems. Thus, the fix is to check for that directory's existence before attempting to iterate over subdirectories. Without this fix, the script errors out on some systems.
In the"__promptline_battery" function of the battery slice, a math error occurs on Mac desktops:
The problem code is here:
if ioreg_output=$(ioreg -rc AppleSmartBattery 2>/dev/null); then
...
local battery_level=$(($current_capacity * 100 / $battery_capacity))
, which upon execution errors out the script with this message:
-bash: * 100 / : syntax error: operand expected (error token is "* 100 / ")
The reason it fails on Mac desktops via Mac laptops (MacBooks) is because desktops don't have batteries! Thus the value of $current_capacity is empty, so the multiplying an empty string by 100 fails.
The fix is to only enter the code block if $ioreg_output is not empty. I will submit a Pull Request that fixes this.
The text was updated successfully, but these errors were encountered: