Fix power checking on OS X
PATCH 1/1 Fix power checking on OS X
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.
--- contrib/hooks/pre-auto-gc-battery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/hooks/pre-auto-gc-battery +1 -1
@@ -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
Signature · 1 line
2.4.1
Quoted 4 lines · Panagiotis Astithas
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 17 lines
Signed-off-by Panagiotis Astithas <[email protected]>---
contrib/hooks/pre-auto-gc-battery +1
-2@@ -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
Quoted 11 lines · Eric Sunshine
Quoted 4 lines · Panagiotis Astithas
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.
Quoted 11 lines · Panagiotis Astithas
Quoted 10 lines · Eric Sunshine
Quoted 4 lines · Panagiotis Astithas
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)?
Quoted 6 lines
Quoted 1 line
(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.
Quoted 11 lines · Panagiotis Astithas
Quoted 10 lines · Eric Sunshine
Quoted 4 lines · Panagiotis Astithas
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)?
Quoted 6 lines
Quoted 1 line
(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.