Concepts
AppleScript has been introduced in GeekTool because some users wanted to extend possibilities in ways that could not be implemented directly into the software.That's why it is a very powerful tool that will let you go far beyond the standard features of GeekTool.
The structure of scriptability in GeekTool is quite simple. The application object is composed of geeklet objects and group objects.
Add the following line as a shell script in GeekTool: cal sed 's/^/ /;s/$/ /;s/ $ (date +%e) / $ (date +%e sed 's/./#/g') /'. And you'll get the current month with today marked off on it right. I have been building up a number of commands that I can use in GeekTool. One that I wanted but couldn't find in other lists was the current battery capacity. One that I wanted but couldn't find in other lists was the current battery capacity. GeekTool is a great application for OS X that allows you to display the contents of shell scripts, images, and files directly on the desktop. This page provides some scripts that I have written or adapted from others I've found to provide useful information on the desktop with GeekTool. GeekTool is a great way to display the results of little scripts on your desktop. Using ANSI color codes can make those scripts even more useful. You can also change the status of the status button from “success” to “failure” depending on your script’s exit code.
Each geeklet object has a set of properties and attached groups.
Each group can be set visible or not, this has the same effect as enabling or disabling groups in the menu or in system preferences.
Example
An easy way to get a list of geeklet objects is to run this simple script in Script Editor :
This produces an output like this :
As you can see, geeklets are referenced by their ID. This ID is generated when you create the Geeklet from System Preferences, and is unique.
A convenient way to get the ID of a given geeklet is to open GeekTool Preferences, select a geeklet, and double click on the bottom of the inspector palette where the ID is displayed. This will copy the ID in the pasteboard.
You can also get a given geeklet by its name, as long as you did set one in the inspector, like this :
It should return an output similar to this one :
Best Geektool Scripts
Now you know how to reference Geeklets, let's see what you can do with it.
Manipulating Geeklets
This shows how to hide or show individual geeklets :
The only way to get it back is to set the property back to true, or relaunch GeekTool.
This flag will totally ignore groups settings. It will show, or hide a geeklet without checking if the geeklet should be visible or invisible according to currently enabled groups.
Manipulating groups
Here is how you can show or hide groups.
Geektool Mac Scripts
Refreshing geeklets
Another useful feature is the refresh (or refresh all) command
This will refresh all geeklets eligible to a refresh action (not File, which are continuous)
tell application 'GeekTool Helper' to refresh all
This will refresh a specific geeklet
tell application 'GeekTool Helper' to refresh geeklet id 'CAD821B6-EBC9-42CF-ADDC-AB3A473D1D7B'
Note the short notation used here, without tell / end tell block, this is standard AppleScript shortcut.
A long form would be :
Getting GeekTool dictionary
There is a little trick to get the GeekTool dictionary in Script Editor because the actual scriptable application is hidden into the .prefPane bundle.
- In Script Editor, open the Library from the Window menu (Or Shift-Command-L)
- Go to
/Applications
directory in the Finder - Right click (or control click) on GeekTool, and choose 'Show Package Content'
- Go into
Contents/PlugIns/
- Right click (or control click) on GeekTool.prefPane, and choose 'Show Package Content'
- Go into
Contents/Resources/
- Drag and Drop 'GeekTool Helper' application to the Library window of Script Editor
A more complex example
This script displays a dialog where you can select one or multiple geeklet to refresh nowCourtesy of Philippe M.