FL!P



   AppleScript Tips for GeekTool 3



Subject AppleScript Tips for GeekTool 3
Posted 6/17/2009; 2:38 PM by Philippe Martin
Last Modified 6/18/2009; 7:40 PM by Philippe Martin
In Response To (#Top of Thread.)
Label None. Read 2578
<<PREVIOUS NEXT>> TOP THREAD EDIT REPLY
.

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:

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 "GeekTools" to refresh all

These scripts can be called from Apple's AppleScript Menu, Keyboard Maestro, and so on.

.
<<PREVIOUS NEXT>> TOP THREAD EDIT REPLY
ENCLOSURES

None.
REPLIES

None.





This site managed with Conversant, © Copyright 2010 Macrobyte Resources

Site Managed with Conversant