Skip to content

Commit a453cca

Browse files
authored
Merge pull request #34 from mdrocan/check_charging
improved check for discharging state
2 parents 7eae4a1 + 98bb9f9 commit a453cca

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

charging_level.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ batterylevel=$(pmset -g batt | sed 1d | awk '{print$3}' | sed 's/..$//')
44

55
charge_state=$(pmset -g batt | sed 1d | awk '{print$4}' | sed 's/.$//')
66

7+
charge_state2=$(pmset -g batt | sed 1d | awk '{for (i=4; i<NF; i++) printf $i " "; print $NF}')
8+
79
notification30 () {
810
osascript -e 'display notification "Battery level below 30%." with title "Check charging!"'
911
}
@@ -18,7 +20,7 @@ else
1820
exit 0
1921
fi
2022

21-
if [ "$charge_state" = "discharging" ]; then
23+
if [ "$charge_state" = "discharging" ] || [ "$charge_state2" = "AC attached; not charging present: true" ]; then
2224
charge_state_inactive
2325
else
2426
exit 0

0 commit comments

Comments
 (0)