Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kingpixels

macrumors newbie
Original poster
Dec 16, 2012
1
0
I found a script for RAM, that shows a certain amount of bars depending on the used memory:

Code:
mUSED=`top -l 1 | grep PhysMem: | awk '{print $8}'`
mFREE=`top -l 1 | grep PhysMem: | awk '{print $10}'`
G="G"
M="M"
if [ `echo ${mUSED: -1:1}` = `echo ${mFREE: -1:1}` ]
then
	USED=`top -l 1 | grep PhysMem: | awk '{print "X"int($8/($8+$10)*50)"X"}'`
else
	if [ `echo ${mUSED: -1:1}` = $M -a `echo ${mFREE: -1:1}` = $G ]
		then
			USED=`top -l 1 | grep PhysMem: | awk '{print "X"int($8/($8+$10*1000)*50)"X"}'`
		else
			USED=`top -l 1 | grep PhysMem: | awk '{print "X"int(($8*1000)/($8*1000+$10)*50)"X"}'`
	fi
fi
echo $USED | sed "s/X0X/a/;s/X1X/b/;s/X2X/c/;s/X3X/d/;s/X4X/e/;s/X5X/f/;s/X6X/g/;s/X7X/h/;s/X8X/i/;s/X9X/j/;s/X10X/k/;s/X11X/l/;s/X12X/m/;s/X13X/n/;s/X14X/o/;s/X15X/p/;s/X16X/q/;s/X17X/r/;s/X18X/s/;s/X19X/t/;s/X20X/u/;s/X21X/v/;s/X22X/w/;s/X23X/x/;s/X24X/y/;s/X25X/z/;s/X26X/A/;s/X27X/B/;s/X28X/C/;s/X29X/D/;s/X30X/E/;s/X31X/F/;s/X32X/G/;s/X33X/H/;s/X34X/I/;s/X35X/J/;s/X36X/K/;s/X37X/L/;s/X38X/M/;s/X39X/N/;s/X40X/O/;s/X41X/P/;s/X42X/Q/;s/X43X/R/;s/X44X/S/;s/X45X/T/;s/X46X/U/;s/X47X/V/;s/X48X/W/;s/X49X/X/;s/X50X/Y/"

I'm fairly incompetent when it comes to coding Geektool scripts, so I was hoping someone could help me turn this into a battery metre.

The way that it works is that the site provided a font to apply on it, that works like this:

'a' shows as zero bars.
'b' shows as one bar.
'c' shows as two bars.

..and so on, until 'z', which equals 25 bars.
The alphabet restarts then, with capitals.

'A' shows as 26 bars.
'B' shows as 27 bars.
'C' shows as 28 bars.
...
'Y' shows as 50 bars.

The idea is that the RAM metre is out of fifty, so if all ram is used, it would send a 'Y', which would show as 50 bars.

I was hoping someone could help me do the same with battery, so that 100% and 99% would be 'Y', 98% and 97% would be 'X' etc.

Thanks for any help you can provide.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.