The latest release of macOS Sierra (update 10.10.2, if you’re counting) saw an interesting change, as Apple removed a long-standing feature of the Mac user interface.
If you’re running the latest version of Sierra, then try clicking the battery icon in the menu bar: you’ll notice that the ‘Battery time remaining’ estimate is no more.
Although battery estimates are never 100% accurate (there’s a reason they’re called estimates, after all) MacBooks are designed to be mobile, so many users depend on their Mac’s internal battery on a day-to-day basis. Having a rough idea of how much longer your battery is going to hold out for is pretty useful, so understandably some Mac users aren’t too happy with Apple’s decision to remove this feature.
At the time of writing, macOS doesn’t give you a way of re-adding this estimate to your Mac menu bar, so if you want a rough idea of how much longer your current charge is going to last, then you’re going to have to get creative.
In this article, I’m going to show you how to use the GeekTool app to create a widget, or “geeklet,” that allows you to see this missing battery estimate information, from the comfort of your Sierra Desktop.
Getting Started with GeekTool
Start by downloading and installing the latest version of GeekTool. You can download GeekTool for free, but as with all free software you should consider making a donation to help support the work of the developer.
Launch GeekTool and the first screen you’ll see is the main GeekTool window.
Although we’ll be focusing on Shell geeklets for the majority of this article, there’s actually four different kinds of geeklet you can create:
- Log. Prints information about system and application activity in plain text format. You can use log geeklets to monitor what’s going on across your Mac, right from your Desktop.
- Web. Allows you to display content pulled from the Internet. Alternatively, you can run your own HTML code inside a Web geeklet.
- Image. Displays image-based content, such as network graphs, video streams or a slideshow of images. These visuals can either update automatically based on a schedule, or in response to certain events.
- Shell. These are one of the most flexible and powerful kinds of geeklets you can create, allowing you to run any Shell script and display the results of those scripts on your Desktop.
Along the right side of the window you’ll also find some configuration options for GeekTool as a whole:
- Enable. Toggle this checkbox on and off, to enable and disable GeekTool. You’ll need to have GeekTool enabled before you can create and use geeklets.
- Automatically launch at login. Start GeekTool as soon as you log into your account. If you want your geeklets to be running constantly, then you should set GeekTool to launch automatically at login.
- Show in menu bar. Add a GeekTool icon to your Mac’s menu bar.
To create a geeklet, select one of the four geeklet icons (log, shell, image or web) and then drag this icon from the GeekTool window and drop it onto your Desktop. This creates a rectangular containment box on your Desktop, and opens a ‘Properties’ menu that contains all the options for configuring this particular geeklet.
The ‘Properties’ menu includes options for making cosmetic changes, such as altering the size of the geeklet’s text and its position inside the containment box. You can also make functional changes, most notably adding scripts to your Shell geeklets. This process will vary slightly depending on the kind of geeklet you want to create, but these are the fundamental steps underpinning every geeklet you create in GeekTool.
Creating a ‘Battery Time Remaining’ Geeklet
Now you have an overview of how GeekTool works, let’s get stuck into creating our battery geeklet:
This will open an external script editor, which you should use whenever you need to create a script that’s longer than one line. Copy/paste the following code into this editor, making sure not to alter any of the whitespace between each line:
isFullyCharged=`ioreg -n AppleSmartBattery | grep FullyCharged | awk ‘{ print $5 }’`
timeLeft=`ioreg -n AppleSmartBattery | grep TimeRemaining | awk ‘{ print $5 }’`
if [ $isFullyCharged = “Yes” ] ; then
echo “~”
else
((hour=$timeLeft/60))
((min=$timeLeft-$hour*60))
echo “$hour:$min”
fi
Click the red cross in the editor’s upper-left corner and, when prompted, confirm that you want to save your changes. The containment box on your Desktop will then update to display your device’s estimated battery life.
This estimate will change over time, so make sure you specify how often this geeklet should update, by entering a value into the ‘Refresh every’ field. If you don’t specify a refresh rate, then your geeklet will never update.
At this point, you’ll probably want to make some changes to the size and style of your geeklet’s text. Select the ‘Click here to set font & color….’ button, which will open the system’s standard ‘Fonts’ window.
This window contains a wealth of options for customising your text, including changing its colour so it’s easier to read against your particular Desktop background, and altering the size of the text. By default, geeklet text is a bit on the small side so you’ll probably want to scale it up a few points.
Once you’re happy with your text’s appearance, you should resize the containment box so it’s a little larger than your text. To resize a geeklet, grab the arrow icon in the bottom-right of the containment box and drag it.
You may also want to tweak the geeklet’s position on your Desktop – simply grab the widget, drag it to the new position, and drop it.
Enhancing your Battery Widget
At this point, you’ve created a widget that displays your Mac’s estimated battery life, but there’s a couple of ways of getting more out of this widget that you may want to try.
Firstly, at the moment this geeklet is just a series of numbers with no context. If you share your Mac with other people, then chances are they won’t be able to tell what these numbers mean. And, even if you’re the only person using this particular MacBook, then you may still not be a fan of seemingly random numbers floating around on your Desktop.
If you want to provide your geeklet with some additional context, then you can either add a text label explaining what these numbers mean, or you can add an icon. Conveniently, you can add both of these to your Desktop, by creating an additional geeklet.
Displaying Static Text
To create a geeklet that exists solely to display the same piece of static text:
- Grab a new ‘Shell’ item and drop it onto your Desktop.
- In the ‘Properties’ window, select the ‘Override text’ checkbox.
- In the accompanying ‘Override text’ field, enter whatever text you want to display – I’m opting for ‘Battery time remaining.’
- Style this text. I’m going to use the same colour as my original geeklet, but a smaller font. Spend some time experimenting to see what works best for your particular Desktop.
- Resize the containment box so it’s a little larger than your text.
- Move the geeklet so it appears alongside your original battery geeklet. Note that it’s perfectly fine for containment boxes to overlap.
Displaying A Static Image
Alternatively, you may prefer to display an image alongside your battery geeklet.
Start by deciding what image you want to display. You can either perform a quick Google search (something along the lines of “mac battery icon” should work) and download the image you want to use, or if you’re feeling creative you can boot up your favourite image editing software and create your own image.
Once you have an image, you’re ready to create your geeklet:
- In the main GeekTool window, find the ‘Image’ icon and drag it onto your desktop.
- In the ‘Properties’ window, find the ‘Set local path’ button and give it a click.
- Select the image you want to use.
- Resize your geeklet, if required. Note that resizing the containment box will affect the size of the image.
- Drag the image geeklet into position alongside your original battery widget.
Displaying more battery stats
At this point you have a fully-functioning geeklet that displays the time remaining until your battery hits zero percent – but this is just an estimate. If you want a more accurate insight into how long your battery is going to last, then you may want to create a second geeklet that displays some hard, cold facts about the state of your battery.
One option is to create a second geeklet that displays the total amount of charge your Mac’s battery can hold, in Milliamp Hour (mAh) units, compared to how many mAh units are currently remaining.
To create this supplemental widget, drop a new ‘Shell’ geeklet onto your Desktop and then copy/paste the following script into its ‘Command’ field:
system_profiler SPPowerDataType | grep mAh
Enter a refresh rate, and then style, resize and position the widget as desired.
Some Alternatives
If you only want to check the state of your battery every now and again, then it might not be worth going to all the effort of creating a special widget. If this is the case, then there’s several alternatives you may want to try, including two methods that make use of software already installed on your Mac.
1. Activity Monitor
You’ll find a battery estimate in your Mac’s Activity Monitor, which you can launch by navigating to Applications>Utilities>Activity Monitor. Make sure Activity Monitor’s ‘Energy’ tab is selected – you’ll find the ‘Time on battery’ estimate towards the bottom of this window.
2. Terminal
You can also get a battery estimate by issuing a Terminal command. Launch your Mac’s Terminal (Applications>Utilities) and then type the following command into the Terminal window:
pmset -g batt
Hit the ‘Enter’ key on your keyboard and the Terminal will return the percentage of battery remaining, plus an estimate of how long this charge will last.
4. Battery Monitor
Finally, if you want to access the battery estimate as part of your Mac’s menu bar, then you may want to try the third-party Battery Monitor app.
Battery Monitor adds a battery icon to the menu bar; click this icon and it’ll open a dropdown menu containing a visual representation of the amount of battery consumed vs. your battery’s total capacity, alongside an estimate of how long this remaining charge will last.
Add Comment