dolmen / angel-PS1

Your fancy shell prompt fed by your guardian angel

Home Page:https://twitter.com/nglPS1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"pmset -g batt" parsing error on MacOS

aero opened this issue · comments

commented

When 100% charged on MacOS.

$ pmset -g batt
Now drawing from 'AC Power'
 -InternalBattery-0 (id=4718691)	100%; charged; 0:00 remaining present: true

$
$ eval `./angel-PS1`
angel installed.
Use of uninitialized value $1 in division (/) at ./angel-PS1 line 2183.

the following code can't parsing the result

      return sub {
          my $pmset_batt = `pmset -g batt`;

          # 37%; AC attached; not charging
          # 8%; charging; 2:46 remaining
          # 9%; discharging; (no estimate)
          # 7%; discharging; 0:13 remaining
          $pmset_batt =~ m/\t([0-9]+)%;.* (dis)?charging/;
          my $level = $1 / 100;
          my $charging = ! defined $2;

          return ($level, $charging);
      }