A few more GeekTool tricks
I've recently started using GeekTool a lot, and since I posted tips for displaying iCal events and Tweets on the desktop, I've found a few more cool things you can do.
Show Basic System Information
It is possible to use shell commands in GeekTool to display the computer name, operating system version, the amount of RAM and the processor details. This is useful if you have loads of the same model, or if you often remotely control other Macs.
To display this information, just open up System Preferences and click on GeekTool (download it first if you haven't already). Create a new entry, and change the type from File to Shell. Paste the following code into the box:
You might notice that each line of the code corresponds to a line of the output. In fact the code is actually 4 separate terminal commands. If you want you can delete or modify any of the lines and it won’t affect any of the others. Just make sure each line ends with a semicolon.
These details pretty much never change, so it's worth changing the refresh time to something very high. It is measured in seconds, so something like 100000 (about one day) should be alright. Once you adjust the font, colour and position, the result looks something like the screenshot below.
Show Free Disk Space
Just add this into GeekTool in the same way as usual. "
The second part of the command is awk which rearranges the output. You can change this arround. Just make sure all text is inside double-quotes, and all variables (e.g. $2) are outside. $2 gives the capacity, $3 gives the used, $4 gives the free, and $5 gives the percentage used.
This one would fit quite well with the system info above, but it is likely to change more so you might want to keep it separate and have it refresh more often.
Display Album Artwork and Song Details of iTunes Currently Playing
I won't go into detail with this, because I don't have it set up on my system. This basically involves using AppleScript to get the details from iTunes. The song details are relatively straightforward to get, but the album artwork is a bit more complicated. Mac OS X Hints shows how to do the song details here, and the album artwork here.
Display a One-line Weather Forecast
Unfortunately this one is for US readers only (or people who want to know the weather in the US). The website Weather Underground gives a single line weather forecast that just compares today or tomorrow to the previous day. As usual, just create a new GeekTool entry, change the type to Shell and paste the following in the box:
Replace 12345 with your zip code, and you should have a weather forecast for your area. Running this takes a bit of time and system resources, so it's best to change the refresh rate to at least a few hours (about 10000).
Stop GeekTool preventing Sleep
You may have noticed that GeekTool prevents your Mac from going to sleep after the time period set in the Energy Saver section of System Preferences. The display will sleep, but the computer itself will never sleep because it is continuously performing tasks and Mac OS X doesn't think it is idle. This isn't really an issue for me, as I normally close the lid of my MacBook when I'm not using it, but I can see how this would be a problem for others. There is a solution explained over at Mac OS X Hints that uses an application called SleepWatcher to disable GeekTool as soon as the display goes to sleep.
Show Basic System Information
It is possible to use shell commands in GeekTool to display the computer name, operating system version, the amount of RAM and the processor details. This is useful if you have loads of the same model, or if you often remotely control other Macs.
To display this information, just open up System Preferences and click on GeekTool (download it first if you haven't already). Create a new entry, and change the type from File to Shell. Paste the following code into the box:
scutil --get ComputerName;
sw_vers | awk -F':\t' '{print $2}' | paste -d ' ' - - -;
sysctl -n hw.memsize | awk '{print $0/1073741824" GB RAM"}';
sysctl -n machdep.cpu.brand_string;
You might notice that each line of the code corresponds to a line of the output. In fact the code is actually 4 separate terminal commands. If you want you can delete or modify any of the lines and it won’t affect any of the others. Just make sure each line ends with a semicolon.
These details pretty much never change, so it's worth changing the refresh time to something very high. It is measured in seconds, so something like 100000 (about one day) should be alright. Once you adjust the font, colour and position, the result looks something like the screenshot below.
Show Free Disk Space
df
is a command line utility for getting information on how much disk space you have free. The following command gets the output of the df command and converts it into a more readable format:df -hl | grep 'disk0s2' | awk '{print $4"/"$2" free ("$5" used)"}'
Just add this into GeekTool in the same way as usual. "
disk0s2
" is the identifier for the hard drive. You can find out what yours is Disk Utility (located in Applications/Utilities). Just click on the hard drive in the list on the left and choose Get Info... from the File menu (Command-I). The Disk Identifier property is near the top of the info window.The second part of the command is awk which rearranges the output. You can change this arround. Just make sure all text is inside double-quotes, and all variables (e.g. $2) are outside. $2 gives the capacity, $3 gives the used, $4 gives the free, and $5 gives the percentage used.
This one would fit quite well with the system info above, but it is likely to change more so you might want to keep it separate and have it refresh more often.
Display Album Artwork and Song Details of iTunes Currently Playing
I won't go into detail with this, because I don't have it set up on my system. This basically involves using AppleScript to get the details from iTunes. The song details are relatively straightforward to get, but the album artwork is a bit more complicated. Mac OS X Hints shows how to do the song details here, and the album artwork here.
Display a One-line Weather Forecast
Unfortunately this one is for US readers only (or people who want to know the weather in the US). The website Weather Underground gives a single line weather forecast that just compares today or tomorrow to the previous day. As usual, just create a new GeekTool entry, change the type to Shell and paste the following in the box:
curl -s http://www.wunderground.com/cgi-bin/findweather/getForecast?query=12345 | awk '/Today is/ || /Tomorrow is/' | textutil -convert txt -stdin -stdout -format html
Replace 12345 with your zip code, and you should have a weather forecast for your area. Running this takes a bit of time and system resources, so it's best to change the refresh rate to at least a few hours (about 10000).
Stop GeekTool preventing Sleep
You may have noticed that GeekTool prevents your Mac from going to sleep after the time period set in the Energy Saver section of System Preferences. The display will sleep, but the computer itself will never sleep because it is continuously performing tasks and Mac OS X doesn't think it is idle. This isn't really an issue for me, as I normally close the lid of my MacBook when I'm not using it, but I can see how this would be a problem for others. There is a solution explained over at Mac OS X Hints that uses an application called SleepWatcher to disable GeekTool as soon as the display goes to sleep.
blog comments powered by Disqus