# [PATCH] Fix power checking on OS X

5 messages from 2015-06-11 to 2015-06-12. Participants: Panagiotis Astithas, Eric Sunshine, Junio C Hamano.
Thread: https://gitlist.dev/t/39598

## Panagiotis Astithas, 2015-06-11 14:37

Subject: [PATCH] Fix power checking on OS X
Message-ID: <1434033445-35903-1-git-send-email-pastith@gmail.com>
URL: https://gitlist.dev/e/1434033445-35903-1-git-send-email-pastith%40gmail.com

```
The output of "pmset -g batt" changed at some point from
"Currently drawing from 'AC Power'" to the slightly different
"Now drawing from 'AC Power'". Starting the match from "drawing"
makes the check work in both old and new versions of OS X.

Signed-off-by: Panagiotis Astithas <pastith@gmail.com>
---
 contrib/hooks/pre-auto-gc-battery | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
index 9d0c2d1..6a2cdeb 100755
--- a/contrib/hooks/pre-auto-gc-battery
+++ b/contrib/hooks/pre-auto-gc-battery
@@ -33,7 +33,7 @@ elif grep -q "AC Power \+: 1" /proc/pmu/info 2>/dev/null
 then
 	exit 0
 elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |
-	grep -q "Currently drawing from 'AC Power'"
+	grep -q "drawing from 'AC Power'"
 then
 	exit 0
 fi
-- 
2.4.1

```

## Eric Sunshine, 2015-06-12 03:46

Subject: Re: [PATCH] Fix power checking on OS X
Message-ID: <CAPig+cRzKpCePO0gXy7Rok4X7=r6tas28tv48g92YzP9tVP2AA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRzKpCePO0gXy7Rok4X7%3Dr6tas28tv48g92YzP9tVP2AA%40mail.gmail.com
In-Reply-To: <1434033445-35903-1-git-send-email-pastith@gmail.com>

```
On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas <pastith@gmail.com> wrote:
> The output of "pmset -g batt" changed at some point from
> "Currently drawing from 'AC Power'" to the slightly different
> "Now drawing from 'AC Power'". Starting the match from "drawing"
> makes the check work in both old and new versions of OS X.

Would it make sense to try to future-proof this further by searching
only for "'AC" (including the leading single-quote) or just "AC"
(without the leading quote)?

(Genuine question. I don't have a strong feeling about it.)

> Signed-off-by: Panagiotis Astithas <pastith@gmail.com>
> ---
> diff --git a/contrib/hooks/pre-auto-gc-battery b/contrib/hooks/pre-auto-gc-battery
> index 9d0c2d1..6a2cdeb 100755
> --- a/contrib/hooks/pre-auto-gc-battery
> +++ b/contrib/hooks/pre-auto-gc-battery
> @@ -33,7 +33,7 @@ elif grep -q "AC Power \+: 1" /proc/pmu/info 2>/dev/null
>  then
>         exit 0
>  elif test -x /usr/bin/pmset && /usr/bin/pmset -g batt |
> -       grep -q "Currently drawing from 'AC Power'"
> +       grep -q "drawing from 'AC Power'"
>  then
>         exit 0
>  fi
> --
> 2.4.1

```

## Panagiotis Astithas, 2015-06-12 08:53

Subject: Re: [PATCH] Fix power checking on OS X
Message-ID: <CACvVhd7sKiz+gTDY_RVjFf1i3Rt2pYWVsgjewyPHL1ajS5LTcQ@mail.gmail.com>
URL: https://gitlist.dev/e/CACvVhd7sKiz%2BgTDY_RVjFf1i3Rt2pYWVsgjewyPHL1ajS5LTcQ%40mail.gmail.com
In-Reply-To: <CAPig+cRzKpCePO0gXy7Rok4X7=r6tas28tv48g92YzP9tVP2AA@mail.gmail.com>

```
On Fri, Jun 12, 2015 at 6:46 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas <pastith@gmail.com> wrote:
>> The output of "pmset -g batt" changed at some point from
>> "Currently drawing from 'AC Power'" to the slightly different
>> "Now drawing from 'AC Power'". Starting the match from "drawing"
>> makes the check work in both old and new versions of OS X.
>
> Would it make sense to try to future-proof this further by searching
> only for "'AC" (including the leading single-quote) or just "AC"
> (without the leading quote)?
>
> (Genuine question. I don't have a strong feeling about it.)

It's a reasonable idea, although I'm wondering what are the odds of
pmset changing to output a string when running on battery in the
future, containing something like "no longer on 'AC Power'". That's
probably too far out though.

```

## Junio C Hamano, 2015-06-12 14:54

Subject: Re: [PATCH] Fix power checking on OS X
Message-ID: <xmqqr3phdlj3.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqr3phdlj3.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CACvVhd7sKiz+gTDY_RVjFf1i3Rt2pYWVsgjewyPHL1ajS5LTcQ@mail.gmail.com>

```
Panagiotis Astithas <pastith@gmail.com> writes:

> On Fri, Jun 12, 2015 at 6:46 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas <pastith@gmail.com> wrote:
>>> The output of "pmset -g batt" changed at some point from
>>> "Currently drawing from 'AC Power'" to the slightly different
>>> "Now drawing from 'AC Power'". Starting the match from "drawing"
>>> makes the check work in both old and new versions of OS X.
>>
>> Would it make sense to try to future-proof this further by searching
>> only for "'AC" (including the leading single-quote) or just "AC"
>> (without the leading quote)?
>>
>> (Genuine question. I don't have a strong feeling about it.)
>
> It's a reasonable idea, although I'm wondering what are the odds of
> pmset changing to output a string when running on battery in the
> future, containing something like "no longer on 'AC Power'". That's
> probably too far out though.

Once they start drawing from USB-C, they may stop referring to AC
altogether; unless you have a crystal ball, it is futile to spend
too many brain cycles to try futureproofing.

Prediction is very difficult, especially if it's about the future.

```

## Eric Sunshine, 2015-06-12 15:58

Subject: Re: [PATCH] Fix power checking on OS X
Message-ID: <CAPig+cQrVoYdLrcmdw698LX=bgXkBZvyD35+K6yLLP4H-W-N=w@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcQrVoYdLrcmdw698LX%3DbgXkBZvyD35%2BK6yLLP4H-W-N%3Dw%40mail.gmail.com
In-Reply-To: <CACvVhd7sKiz+gTDY_RVjFf1i3Rt2pYWVsgjewyPHL1ajS5LTcQ@mail.gmail.com>

```
On Fri, Jun 12, 2015 at 4:53 AM, Panagiotis Astithas <pastith@gmail.com> wrote:
> On Fri, Jun 12, 2015 at 6:46 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas <pastith@gmail.com> wrote:
>>> The output of "pmset -g batt" changed at some point from
>>> "Currently drawing from 'AC Power'" to the slightly different
>>> "Now drawing from 'AC Power'". Starting the match from "drawing"
>>> makes the check work in both old and new versions of OS X.
>>
>> Would it make sense to try to future-proof this further by searching
>> only for "'AC" (including the leading single-quote) or just "AC"
>> (without the leading quote)?
>>
>> (Genuine question. I don't have a strong feeling about it.)
>
> It's a reasonable idea, although I'm wondering what are the odds of
> pmset changing to output a string when running on battery in the
> future, containing something like "no longer on 'AC Power'". That's
> probably too far out though.

That was my concern, as well, hence not feeling strongly about it.

```
