macfidelity

|

rethinking the think-different thing

mac | Using Geektool to display comics (xkcd) on your Mac OS X Desktop

March 22nd, 2009 at 2:00

20090322_geektool_comics_14

Some days ago i was wondering how to display random comic strips on my Mac OS X Desktop.

Before we’re getting started a short warning:

The following solution is far away from perfect and somehow “dirty”

But who cares about perfect … it’s about getting it done :)

As a big fan of Geektool it is pretty clear that i want to use its Picture function to display the comic strip on the desktop. Unfortunaly Geektool can only handle a full image path – so we can NOT work with wildcards

So we have the following tasks

  • Download selected comic strips from an online source – for sure automated
  • Select random image – using a simple .sh script executed using Geektool
  • Display random image – using the picture function of Geektool

Ready ?

Download material

A simple way to get tons of comic strips in mind ? For sure we could write some fancy script which downloads from random sources but there are other solutions =)

I used iStrip – an application which is designed as comic-viewer. iStrip offers a nice interface to select from a huge list of comic strips and is able to download (they call it caching) those selected comic-strips.

20090322_geektool_comics_01

So basically we just need to install iStrip, select the sources we want to use and enable the caching feature which should save enough material to our local folder.

1. Install iStrip

2. Create a folder which will be later used as storage location for the images. I use a folder called “comic_test” on my Desktop.

20090322_geektool_comics_02

3. Run iStrip and open the Preferences window. Navigate to the Cache tab and enable Cache images locally. You can define the amount of images – i suggest as much as possible cause it will prevent us from running iStrip each day to get new strips.

20090322_geektool_comics_03

Navigate to the Strips tab and select your comic-sources

20090322_geektool_comics_04

After pressing enable you should take a look on the defined comic-storage location. In my case it worked already and i have enough testing material. The subfolder com.xkcd was generated by the caching function of iStrip.

20090322_geektool_comics_06

So … we got strips – task 1 solved.

Select random image

In step 2 we need to select a random image of our new folder “comic_test”. As we want to perform this random-select periodically we need a small script.

1. Create a new subfolder _myRandomImage in the folder comic_test.

20090322_geektool_comics_09

2. Create our select-a-random-image-and-copy-it script and save it as selectRandomImage.sh in our folder comic_test.

20090322_geektool_comics_07

The folder comic_test should look like this now:

20090322_geektool_comics_10

Now we need to execute our script selectRandomImage.sh periodically using Geektool

20090322_geektool_comics_08

As a result we have a new image a.png in our targetfolder /comic_test/_myrandomImage/

20090322_geektool_comics_11

Ok … lets jump to the last task

Display random image

The final step is pretty easy, just create a new task in Geektool to display our random image a.png on your desktop.

20090322_geektool_comics_12

Et voila

20090322_geektool_comics_13

As mentioned at the beginning: ugly as hell – but it works. I hope you enjoy your comic-strip’ed-desktop :)

I guess based on this initial idea you can easily write some more enhanced scripts to modify the behaviour.

Best regards

fidel

Tags: , , , , , , ,

18 Responses to “mac | Using Geektool to display comics (xkcd) on your Mac OS X Desktop”

  1. Kruemel^Nico Says:

    nice nice, aber wo ich gerade iStrip an hab frag ich mich warum du hier nur xkcd an hast ich finde in die auswahl gehört eindeutlich auch NICHT LUSTIG xD

    ReplyReply
  2. fidel Says:

    hehe – absolut recht.

    Ich dachte mir beim schreiben nur: verfolge das KISS-Prinzip
    -> http://de.wikipedia.org/wiki/KISS-Prinzip

    ReplyReply
  3. Krueme1^Nico Says:

    Ich erweitere am besten heute abend mal dein shell script …
    sollte sicher gehen die Ordner davor auch random zu öffnen …
    Wobei man noch einbauen muss, dass der checkt welche ändung die Bilder haben. Bei NL sind es jpg datein. Laut deinem hier bei xkcd png.

    mal sehen mal sehen

    ReplyReply
  4. fidel Says:

    Ja cool – hau rein – ich editier das ganze dann gerne noch nachträglich in den Beitrag rein wenn dein Script fertig ist ;)

    Gruss
    fidel

    ReplyReply
  5. edwford Says:

    Thankyou very much for this. I posted a thread on the XKCD forums trying to get XKCD to display on my desktop, but I couldn’t think of a way to go about it. Thanks again =)

    ReplyReply
  6. fidel Says:

    Hi edwford,

    i think while searching for an solution i even discovered your forum-post there ;)
    Great that you found the solution now here.

    Let me know if you have other geektool-tasks in mind hehe

    Best regards
    fidel

    ReplyReply
  7. Chris Says:

    Hey, that’s about the neatest GeekTool tip I’ve seen so far! However, I was stuck for hours on making the shell script work. Turned out that I had written hyphens (-) instead of equation marks (=) in the “select and copy” line. Felt a bit stupid afterwards. Take heed, all else who follow this wonderful tutorial!

    ReplyReply
  8. Arvindh S. Says:

    Hey!
    I tried copying the code into a text file and then doing chmod 744 on the file. However, it always turns up an error about unexpected EOF while looking for matching ‘ ” ‘

    Honestly, I could not find any difference!

    Here’s my code. Help please!

    CODE BEGINS
    #! /bin/bash

    sp=/Users/Icarus/isc/test
    tp=/Users/Icarus/isc/dest

    ext=’JPG’
    find -E “$sp” -iregex “.*.($ext)” |
    (
    i=0; while read line; do lines[i++]=”$line”; done

    cp “${lines[$RANDOM % $i]}” “$tp/a.$ext”
    )

    CODE ENDS

    Edit: Solved it! Magnifying helps!

    P.S. I’m leaving the corrected code above. It’ll be easier to copy!

    ReplyReply
  9. fidel Says:

    @Chris
    sorry for the confusion.
    I made bad experiences pasting code into wordpress as it seems sometimes some special-characters get lost …. that’s why i just used screenshots.
    Great to hear you managed it finally ;)

    @Arvindh
    a click on the shell-script image should now bring a slightly bigger version of the screenshot.
    … sorry for the time and effort ;)

    ReplyReply
  10. Customize Your Mac Desktop « raxcy Says:

    [...] [...]

  11. Zeto Says:

    Hi fidel,

    I’ve been having trouble writing the shell script for geektool to chose a random image, what program did you use to write the shell script, if possible could you break down how to write the script exactly?

    Thanks,

    Zeto

    ReplyReply
  12. fidel Says:

    @Zeto:

    hi
    …. basically the text-editor you use shouldn’t matter at all – i was using Smultron (http://smultron.sourceforge.net/) in the image above.

    If you open the image above in an image-viewer and zoom in it should be easy for you to reproduce the code.

    If that doesn’t works feel free to ask again and i’ll see what else i can do ;)

    Best regards
    fidel

    ReplyReply
  13. Geektool, quick and dirty way for rotati… « pxldskblg Says:

    [...] Geektool, quick and dirty way for rotating random image on desktop: http://macfidelity.de/2009/03/22/mac-using-geektool-to-display-comics-on-your-mac-os-x-desktop/ [...]

  14. Bob Says:

    I copied your script exactly and I’m getting an error in line 24…

    8812 % 0: division by 0 (error token is “0″)

    :-(

    ReplyReply
  15. fidel Says:

    @Bob
    please double-check the script

    Best Regards
    fidel

    ReplyReply
  16. » Minimalism and the Mac pt 1. :kyle doherty Says:

    [...] Displaying a random Comic Image on your desktop –  via macfidelity.de [...]

  17. IAN Says:

    Hey, when I run the script to make the a.png file, it doesn’t show up. Help please and thank you in advance!

    ReplyReply
  18. edwford Says:

    Hey again, just want to say a simpler way to achieve this is now possible, assuming you are using geektool 3. ^_^ http://www.macosxtips.co.uk/geeklets/images/show-latest-xkcd-comic-with-alt-text/

    Also alt-text =)

    ReplyReply

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>