
AppleScript Tips for GeekTool 3

Scripting Geektool 3
I love GeekTool and I love even more GeekTool 3 that's currently in development.
However it's not feature complete yet and some things you could do with GeekTool 2 (like switching between groups from a menu) aren't implemented in 3 yet. But GeekTool 3 is now scriptable, which allows to do things from the outside that you cannot do yet with GeekTool 3 alone, like displaying/hiding a given geeklet.
The following script shows how I do that.
Update: If you installed GeekTool from the App Store, replace tell application "GeekTool"
with tell application "GeekTool Helper"
.
property geekletId : "E25ED489-C623-481E-91F1-96A2A614A6BF" property cmd : "uptime" property theHeight : 20.0 property theWidth :500.0 tell application "GeekTool" tell geeklet id geekletId if command is "" then set command to cmd set refresh time to 10 set height to theHeight set width to theWidth else set command to "" set refresh time to 0 set height to 0.0 set width to 0.0 end if refresh end tell end tell
Note that changing the height and width of the geeklet is useful only if you gave it a background colour. Also, the command can be set to anything you can enter in GeekTool's command field itself, but if that command contains any double quotes you'll have to escape each of them with a backslash.
The only tricky bit here (unless you're using the fantastic Script Debugger) is to get the geeklet's Id. But here's a way to get a list of every geeklet's id in relation with its command:
tell application "GeekTool" set s to "" set lsGeeklets to every geeklet repeat with aGeeklet in lsGeeklets tell aGeeklet as specifier set s to s & id & tab & (command as string) & return end tell end repeat end tell tell application "BBEdit" activate make new text document in front set text of window 1 to s end tell
And finally you can refresh all the geeklets at once with this simple oneliner:
tell application "GeekTool" to refresh all
These scripts can be called from Apple's AppleScript Menu, Keyboard Maestro, and so on.
Comments
Previous Comments
Below are existing comments.
Comment by Robert Simpson
1. Robert Simpson commented :
Hi. Just what I was needing. Still when using Lion/Applescript I get an error in your script in the tell geeklet id geekId.
It says that it was expecting end of line but found identifier
Is this Applescript version or what?
I got GeekTool 3.0.3
Lion 10.7.3
Applescript Editor 2.4.2 and Applescript 2.2.1 as seen in About Applescript Editor.
Sorry for the next question, Im Objective-C, C++,C and other languages proficient but started to use Applescript for the GeekTool and I dont know to "control/manage" an application like geektool. Which methods or identifiers are accesible and where can I find such a list for geektool.
Thanks.
Robert
Please Log in if you wish to comment.