Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"pmset -g batt" parsing error on MacOS #25

Open
aero opened this issue Jan 17, 2020 · 0 comments
Open

"pmset -g batt" parsing error on MacOS #25

aero opened this issue Jan 17, 2020 · 0 comments

Comments

@aero
Copy link

aero commented Jan 17, 2020

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);
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant