[PATCH] Fix power checking on OS X

Subsystems: the rest

STALE3738d

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] Fix power checking on OS X

From: Panagiotis Astithas <hidden>
Date: 2016-06-15 23:05:16

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 <redacted>
---
 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

Re: [PATCH] Fix power checking on OS X

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:05:16

On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas [off-list ref] 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.)
quoted hunk
Signed-off-by: Panagiotis Astithas <redacted>
---
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

Re: [PATCH] Fix power checking on OS X

From: Panagiotis Astithas <hidden>
Date: 2016-06-15 23:05:16

On Fri, Jun 12, 2015 at 6:46 AM, Eric Sunshine [off-list ref] wrote:
On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas [off-list ref] wrote:
quoted
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.

Re: [PATCH] Fix power checking on OS X

From: Eric Sunshine <hidden>
Date: 2016-06-15 23:05:17

On Fri, Jun 12, 2015 at 4:53 AM, Panagiotis Astithas [off-list ref] wrote:
On Fri, Jun 12, 2015 at 6:46 AM, Eric Sunshine [off-list ref] wrote:
quoted
On Thu, Jun 11, 2015 at 10:37 AM, Panagiotis Astithas [off-list ref] wrote:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help