philwilson.org

a geek commodity

Post to Twitter from Ubuntu Deskbar

March 19th, 2007 by Phil

Deskbar is a Gnome widget you can embed in a panel and can be used for opening applications, opening items from your browser history, doing web searches and all sorts. It’s not as good as Quicksilver but better than Launchy. It fires when you hit a key combo (mine is CTRL+SPACE) and looks a bit like this:

Screenshot of Deskbar on Ubuntu

For the soulless, Twitter is length limited asynchronous multicast IM, for everyone else, it’s a nice way to keep up to date with what your friends are doing using the web, IM or SMS. My rarely-posted to Twitter page is here.

Lucky for me, Deskbar is easily extendable , and so that’s just what I’ve done. I looked at the Twitter Wiki, found a Python Twitter library downloaded their little icon thing and written a sript to let you post to Twitter from your Deskbar. It looks like this:

Screenshot of Deskbar with Twitter plugin installed

To install:

  1. Install python-twitter
  2. Grab deskbar-twitter.py and twitter.png and put them in ~/.gnome2/deskbar-applet/handlers/
  3. Open your downloaded deskbar-twitter.py in an editor
  4. Replace TWITTER_USERNAME and TWITTER_PASSWORD with your Twitter details
  5. Replace YOUR_USERNAME with your Ubuntu username

It took longer to write this blog post than the code, so patches welcome.

Tagged: , , | 16 Comments »

16 Responses

  1. The link to your twitter page is busted.

    [And this is a nice hack that might lead to me finally getting a twitter account. Dammit.]

    Posted by Luis Villa on March 19th, 2007 at 6:26 pm
  2. Thanks! Fixed!

    Posted by Phil Wilson on March 19th, 2007 at 7:45 pm
  3. Very nice idea !
    Using it now.

    You can also embed the icon in the python extension, by base64-encoding it and loading at runtime. Also since 2.18 deskbar supports installing by drag and dropping a .py link to the prefs panel and it gets installed automatically. Finally, you should probably add a simple config dialog to store the twitter username and password.

    Very nice work !

    Posted by Raphael Slinckx on March 21st, 2007 at 8:55 am
  4. Thanks very much for that Raphael. I had seen other extensions using base64-encoded icons but none of them worked, so I didn’t bother ;)

    Yes, you’re right about the preferences, but I was too lazy :)

    Posted by Phil Wilson on March 21st, 2007 at 9:59 am
  5. I really like your idea to post to twitter with deskbar, but i cannot get python-twitter to work. First by ubuntu doesn’t recognize the easy_setup command.

    Secondly, i get (after some python traceback calls) the following error rule after I started the python script “setup.py test”:
    pkg_resources.DistributionNotFound: simplejson>=1.5

    What should I do, easy_setup cannot be installed through the repo?

    TIA!

    Posted by mithras86 on April 26th, 2007 at 6:26 pm
  6. Really cool, thanks ;)

    @mithras86:

    Try this:
    wget http://peak.telecommunity.com/dist/ez_setup.py

    sudo python ez_setup.py

    sudo easy_install -U simplejson

    That should take care of the dependencies.

    Best Regards

    Posted by Xlife on April 30th, 2007 at 1:29 am
  7. Yes, that does the trick, thanks a lot!

    Please note you point to the icon “twitter.png”, but provided an icon called “deskbar-twitter.png”, so you should change one of them to get the icon working.

    But furthermore: this is really cool, i’ll post it at forums i’m visiting very often!

    Posted by mithras86 on May 1st, 2007 at 6:48 pm
  8. I’ve put together a more complete twitter plugin for Deskbar. If anyone is interested it’s here

    Posted by Amblin on June 11th, 2007 at 4:49 pm
  9. It’s telling me that the api.Update() method requires exactly two arguments where I supplied four (?!). Anyone else having this problem?

    Posted by Fred on August 21st, 2007 at 6:50 pm
  10. Nice work!

    A small modification required if you want to use it with ptyhon-twitter 0.4:

    @@ -20,8 +20,8 @@ HANDLERS = {
    #It simply always displays “Hello World” in the dropdown list.
    class TwitterMatch(Match):
    def action(self, text=None):
    - api = twitter.Api()
    - api.PostUpdate(‘TWITTER_USERNAME’, ‘TWITTER_PASSWORD’, self.name)
    + api = twitter.Api(‘TWITTER_USERNAME’, ‘TWITTER_PASSWORD’)
    + api.PostUpdate(self.name)
    def get_category(self):
    return “actions”
    def get_verb(self):

    Posted by Ajnasz on September 7th, 2007 at 8:48 am
  11. Excellent, thanks for the patch!

    Posted by Phil Wilson on September 7th, 2007 at 11:23 am
  12. Hi, Thanks a lot for your work.

    I don’t use Twitter but I like the concept, and your tool is perfect

    However, I don’t think everybody wants to go through installing that lib (unless there are distro packages),
    so I made my own version using only HTTP methods (which are included by default I think)

    anyway here is it

    http://ubuntuforums.org/showthread.php?t=554874

    it’s still far from perfect but I tried it and it worked

    Again very nice tool, I think I’ll give this twitter thing a try :)

    Posted by reda on September 20th, 2007 at 1:38 am
  13. Thank guys for sharing you code, I have downloaded them and will roll up my sleeves and start hacking it later this weekend. Will leave a comment to let you know how it goes.

    Posted by Helen Neely on September 27th, 2009 at 10:36 pm
  14. This is a nice piece. I just started using Ubuntu as my main OS and this seems like a good way to get to know my way around it. I will also play with your code and let you know if I can contribute to it.

    Thanks for posting.

    Posted by Evans on November 21st, 2009 at 5:00 pm
  15. Cool. Could you write a plugin for Google Buzz? I think it must be fairly easy to do but I’m the worst programmer ever.

    Posted by Ivan Lezhnjov Jr. on November 18th, 2010 at 6:07 pm
  16. Look kinda neat. My only concern is the bulking up of all layers at the top of web browsers. This leaves less actual page view when we continue to add more horizontal bars. Thanks for the intro to this option. I just plain love twitter. Debby

    Posted by Debby Bruck on May 1st, 2011 at 12:40 am

Leave a Comment




Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.