Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

Commit

Permalink
fixed bug #38 caused by pr #34 (copied forum code with conditional el…
Browse files Browse the repository at this point in the history
…se case if battery max value is not found resulted in ? instead of NULL
  • Loading branch information
childnode committed Dec 2, 2015
1 parent bf8d128 commit 7c9fedd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bin/archey
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

# archey-osx 1.5.3 (https://github.com/obihann/archey-osx/)

# test to see if bash supports arrays
arraytest[0]='test' || (echo 'Error: Arrays are not supported in this version of
bash.' && exit 2)
Expand Down Expand Up @@ -37,6 +39,8 @@ do
opt_offline=t
;;
-h|--help)
echo "Archey OS X 1.5.3"
echo
echo "Usage: $0 [options]"
echo
echo " -p --packager Use auto detected package system (default packager: ${detectedpackager})."
Expand Down Expand Up @@ -76,7 +80,7 @@ uptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
shell="$SHELL"
terminal="$TERM ${TERM_PROGRAM//_/ }"
cpu=$(sysctl -n machdep.cpu.brand_string)
battery=$(ioreg -c AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}')
battery=$(ioreg -c AppleSmartBattery -r | awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; if (max>0) { print 100*c["\"CurrentCapacity\""]/max;} }')

# removes (R) and (TM) from the CPU name so it fits in a standard 80 window
cpu=$(echo "$cpu" | awk '$1=$1' | sed 's/([A-Z]\{1,2\})//g')
Expand Down

0 comments on commit 7c9fedd

Please sign in to comment.