Geektool Scripts For Word

Scripts

A Couple GeekTool Scripts Published on 11 Jan 2010 Filed in Explanation 451 words (estimated 3 minutes to read) I’ve been experimenting with GeekTool, a nifty Mac OS X Preference Pane that allows you to display information on your desktop. This information can be static text, images, or the output of a script. Write a script using style set forth in this accessible template; it has space for a title, address, and an example script to demonstrate the style. Create an amazing story and bring your characters to life on the big screen with this simple script template for writing a screenplay. Write a script using style set forth in this accessible template; it has space for a title, address, and an example script to demonstrate the style. Create an amazing story and bring your characters to life on the big screen with this simple script template for writing a screenplay. Office Scripts documentation. Use Office Scripts in Excel on the web to automate your common tasks. Explore the following articles to learn how to create and edit Office Scripts and get started automating today. GeekTool is a utility that allows you to embed objects and information directly onto your Mac's desktop. It installs as a preference pane in the System Preferences, and from there you can open use.

Adding Twitter into GeekTool using OAuth!

Geektool

I’ve been playing around with GeekTool recently and one of the first things I wanted to include was my Twitter timeline on my desktop which proved to be a more difficult task than I expected..

The main issue was any existing Twitter GeekTool scripts I found used basic authentication which is no longer supported by the Twitter API as it was replaced with OAuth authentication (which is good, but makes accessing the API authenticated a bit more difficult).

I wasn’t having much luck until I started searching for a command line Twitter access using OAuth… then I stumbled on a blog post containing a Python script which could retrieve user timelines, post tweets etc. designed to run using OAuth.

It worked fine out the box, but after a bit of manual configuration, I started adding some pretty formatting then found myself adding some new features like a Twitter search or retweet monitoring etc….

I then integrated the OAuth app/token creation, while trying to make it as user-friendly as possible, limiting the amount of prerequisites to run this script to a minimum. I’ve tested this script using the latest version of GeekTool (available in the Mac App Store) using OSX Lion, It should work… but as a disclaimer I’m throwing this up as a ‘work in progress’ script, but should get the job done.

It has come to my attention: That GeekTool sometimes will not see the full path to python2.7, I believe it was working on my system because I have Xcode installed. I have amended the script to print an example line using full paths for GeekTool, but can only test this on my system. (which appears to work.)

STEP 1:

Well python comes pre-installed on OSX so you shouldn’t need to install anything new, but we do need to get the 'Tweepy’ package to talk to the Twitter API.

The easiest way I found to install this was via the terminal using the following command:

Geektool scripts for wording

This works but only seems to apply to python2.7 if I cared enough I would maybe try to work it out for the default version of python (2.5) but the path of least resistance means that to run the script we are just going to use python2.7 to execute it. :/

Update: In recent updates I have made the script compatible with Python2.5 -> Python2.7, I’ve documented my experience in installing the required packages on my GitHub Wiki.

STEP 2:

Download the script (now from GitHub) extract it and place the script somewhere safe so it doesn’t get moved etc. The file may not be executable with the default permissions.. so via command line run the following command:

Update: If you download the package from GitHub it should have the correct permissions so you can most likely ignore this step.

STEP 3:

Next run the script using the python version that is set up with Tweepy via the terminal, On first run it will help you setup a OAuth application allowing you to connect to the Twitter API authenticated. I’ve tried to make this as easy as possible. I’ve added the -a option to the command but technically you shouldn’t need to add it unless you want to reset your OAuth authentication file.

or

or

Pretty much you go to the Twitter dev site and create an application then enter your ’Consumer Key’ and ’Consumer Secret’ when prompted.

This will then attempt to generate your 'Access’ tokens asking you to go to an Authorisation URL giving you a PIN number to enter.

Hopefully you should have no issues, enter the PIN code that is generated, then your OAuth access authentication tokens will be created and saved to the configuration file. This will allow you to run the script and pull down your Twitter timelines using your OAuth authentication tokens.

Update: After the OAuth setup is complete, it will display the full path of python and the currently location of the script. (If you have trouble adding this GeekTool this example line should work..)

Step 4:

You should be able to test if it has worked by running the command line:

or

or

It will hopefully have displayed your latest 30 tweets in your timeline, hopefully by now you have guessed this is the type of shell command you would configure into GeekTool but making sure to add the full path to the script.

Here is a screenshot of my desktop using GeekTool and the -rtm command, I’m assuming because these are retweets, they are public accounts and/or the information displayed in this screenshot is public… :/

Adding Script into GeekTool:

GeekTool runs all scripts from the root directory so when you add the Twitter script into GeekTool you will need to use the full path to the script for it to run properly. Using the command line type in the command:

Geektool Scripts For Word Search

pwd

This will give you an output of your current working directory, the default output should be /Users/<username> but for completeness you should run the command to be absolutely sure. You can run the script from anywhere on your computer but I believe best practice is to create a new folder to store all your GeekTool scripts in (so you don’t delete or move the file/folder accidentally.) A few examples of different places to create your GeekTool scripts folder:

Next you need to open the GeekTool preferences and drag a 'Shell’ module to the desktop. These are the settings that I use:

Name: Twitter Feed Command: python2.7 /Users/<username>/geektool-scripts/twittercli.py -t -c30*You may need to put the full path to python* Refresh every: 300 (seconds) Font: Menlo (size 10) Alignment: Left
Geektool

This should get you started, I’ve added a few other features like showing mentions and retweets etc. I haven’t documented fully but info for these in a options is available running the ’–help’ option.

NOTES:

  • You should add an generous refresh time in GeekTool to prevent being rate limited by the Twitter API. (I use 5 minutes)
  • The formatting only works properly with a monospace font.. (I use Menlo)
  • Some fonts if they are too small the bolding doesn’t work… :/
  • For the Twitter search option use quotes, otherwise it will only work for one word, and if that one word starts with a hash (#) python and/or bash will ignore it.. :/
  • I realise my code is a bit dodgy consider this an Alpha release…
  • Script is somewhat work in progress/beta.

Finally:

So hopefully, this post should at least get you on the right track. I’m planning to do some updates/streamline the process, any feedback is welcome…

Incase you missed it, the script file is here: https://github.com/gmanual/Twitter-OAuth-GeekTool-Script

Geektool Scripts For Word Processor

Update:

  • Updated script to Version 0.1, better argument handling using ’argparse’, I believe this means this script now 100% requires python2.7 but pushing ahead, search is broken until I fix, but pushing update because I think this is an important update.
  • Updated script to Version 0.2, fixed search and implemented custom number of results (default is 30)
  • Updated script to Version 0.3, code optimisation/restructure, I’m a lot happier with this code than the orignal.
  • Updated script to Version 0.4, implemented a change/feature: If script is run and no auth details are found it will prompt to run OAuth setup, if OAuth settings are detected it will display by default your home timeline.
  • Updated script to Version 0.5, fixed potential bug in determining config file location, going though supported Twitter API commands and adding them one by one. Latest public tweets added in this version. I am also looking at implementing some form of caching.
  • Updated script to Version 0.6, code optimisation/restructure, checks if you can connect to the Twitter API, if it can not it will print a nice message. (Sanity checking for if you are offline.) No caching yet.
  • Updated script to Version 0.7, fixed OAuth setup bug (not really a bug but kinda was), also added direct messages support. You will need to enable extra permissions on your Twitter App to view direct messages.
  • Updated script to Version 0.8, added -e option to show an example GeekTool command pulling full paths for both python2.7 and your script location. (This should help if you don’t know much about scripting etc.) Note: This was a quick hack while I’m out-of-town, I will look into better ways of performing this once I’m home.
  • Updated script to Version 0.9, added -n option to add spacing between tweet output.
  • Updated script to Version 1.0, no functionality added but code is now commented. I had always planned if I made it to Version 1.0 I would add a code project page which has now been done on GitHub.

Geektool Scripts For Word Document

Another Update:

I’ve added this script to a GitHub open source project found here: Twitter-OAuth-GeekTool-Script

Geektool Scripts For Wordpress

All issues should be reported here or if you want to watch the project to get updates this is probably the best place to do so.