My GeekTool Setup

geektooldesktop
I recently posted my "April" desktop on Filckr. Since then I've gotten a few requests for some of the GeekTool code. So here goes…

Let's start with the easy stuff.

Calendar
cal
cal
Refresh: 300s, Font: Monaco
Pretty self-explanitory. It just brings up a calendar of the current month

Time
time
date '+%I:%M %p'
Refresh: 10s, Font: Helvetica Neue
The date command is pretty flexible. It's used often in my setup. The format string at the end is fairly basic, too. The '+' just signifies a user-defined format. %I is hours, %M minutes, and %p is the AM/PM designation. I really wanted to find a way to turn the AM/PM on 90°, but I don't think it's possible with GeekTool. The single quotes are necessary since there is a space in the format string.

Current Date
date
date +%d
Refresh: 300s, Font: Helvetica Neue
Again, date command. %d is the current day of the month.

Current Month
month
date +%B
Refresh: 300s, Font: Helvetica Neue
%B - current month, non-numeric

Day of the Week
day
date +%A
Refresh 300s, Font: Helvetica Neue
Self explanitory.

Now the fun parts:
Current Weather Conditions
weather
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USWI0455&u=f" | grep -E '(Current Conditions:|F<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's///' -e 's/<\/description>//'
Refresh: 1800s, Font: Helvetica Neue
That's a mouth full. Let's take this one piece by piece.
curl will take a url and dump the server response, most often the raw HTML. The '--silent' flag prevents curl from outputting a progress meter or error messages. The url of Yahoo's weather page follows in quotes. "CITYDATA" should be replaced with your results when you search for your city/zip on their site.
grep is a command line search utility. We're basically searching for the part of the XML file that starts with "Current conditions" and ends with "F
sed is basically taking out grep search results and paring it down to just the bit we want: the text of the current conditions.

IP Addresses:
ip
myen0=`ifconfig en0 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen0" != "" ]
then
echo "$myen0"
else
echo "INACTIVE"
fi
myen1=`ifconfig en1 | grep "inet " | grep -v 127.0.0.1 | awk '{print $2}'`
if [ "$myen1" != "" ]
then
echo "$myen1"
else
echo "INACTIVE"
fi
wip=`curl --silent http://checkip.dyndns.org | awk '{print $6}' | cut -f 1 -d "<"`
echo "$wip"

Refresh: 60s, Font: Helvetica Neue
Yay full-on scripts! In simple words, this pulls the IP addresses from the ifconfig command for each interface (ethernet: en0, airport: en1). The fun bit comes in with the if-then statements. If no IP address is returned, it outputs "INACTIVE" instead of just a blank space. It just looks a little nicer. The last bit gets our external IP using curl on dyndns.org.
If you're wondering where the labels are in this code (Ethernet, Wireless, External). They're in a separate script with echo commands. It was just easier to get the spacing down that way.

Transmit Rate
transmitrate
mytr=`airport -I | awk '/lastTxRate/ {print $2}'`
if [ "$mytr" != "" ]
then
echo "Airport Transmit Rate: $mytr"
fi

Refresh: 5s, Font: Helvetica Neue
For some reason, my Leopard installation has trouble with keeping the transmit rate up. So I monitor it with this command. Now, by default, the airport command is not readily accessible. We make it that way with the following command in Terminal (found here):
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
awk is another way of just pulling the info out we need, in this case "lastTxRate." the print $2 command limits the output to the second 'word,' in this case, the transmit rate in Mbps.

Uptime
uptime
uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print "Uptime: " $3$4$5$6}'
Refresh: 300s, Font: Helvetica Neue
Okay, this one is sloppy. I'm sure there is a better way to do this, but I just haven't found it. The code was cobbled together from this forum post and modified to work a little better. But I still get weird output for the first 60 minutes of uptime.
What does this do? uptime displays a few stats, but we're just interested in the hours, minutes, and days the computer has been up. Not number of users, etc. So this script just outputs and reformats that bit. All the sub commands substitute one bit of text for another. For example, instead of 'mins' I just wanted 'min', and instead of "3:42", I wanted it to say "3h 42min."
If anyone has any suggestions on how to clean this up or how to stop if from displaying the logged in users during the first 60 minutes (eg "15min1"), I'd love to hear it.

Now, my proudest moment:
Current Weather Image
weatherpic
Image URL - PHP script on my server
Refresh: 300s
The interesting bit isn't in GeekTool, but in the PHP script I wrote:
<?php
$url="http://weather.yahoo.com/forecast/CITYDATA.html"; //Yahoo Weather URL. Sub CITYDATA for your code.

$divStart = "<div class="\"forecast-icon\"";">$strEnd = "'); _background-image/* */: none;"; //HTML after weather image
$start = strpos($file_contents, $divStart) + 50;
$end = strpos($file_contents, $strEnd);
$length = $end-$start;

$imagepath=substr($file_contents, $start , $length); //Pulls path to image
$image=imagecreatefrompng($imagepath); //Pulls image source into PHP
imagealphablending($image, true); //Enable alpha blending (important)
imagesavealpha($image, true); //Applies alpha to image.

header('Content-Type: image/png'); //Identifies itself as a PNG image
imagepng($image); //Outputs image contents
?>

I tried to comment the code as best I can, but basically, it just pulls the raw HTML from Yahoo weather, extracts the image url for current conditions, and spits out that image data as if the script itself were that image. I might be violating some TOS, though, so your mileage may vary.

So that's my GeekTool setup. There's even more impressive things that people are doing like pulling Twitter feeds, so I suggest you hit up Google.

UPDATE (2009/04/16): Apparently some people have been having problems with these scripts. Due to the formatting in WordPress, there may be some new line feeds or line wrapping that is preventing the scripts from working properly. And though I've been pretty thorough, there may be a place or two where it ate some HTML. In any case, I'm attaching a text file that has all the shell scripts and another text file with the PHP (which should be renamed with the .php extension before using)

Share:
  • Digg
  • Reddit
  • StumbleUpon
  • del.icio.us
  • Facebook
  • MySpace
  • E-mail this story to a friend!
  • Kat Ingalls
    **FINALIZED IMAGE DIRECTIONS**

    1. Go to: http://free.jbuc.com/weatherIm.... Follow the directions given
    3. Find link at the end of tutorial 
    4. Paste as "URL" for IMAGE geeklet

    FOR CLARIFICATION:
    - You don't need your own server
    - You don't need to use a shell script - only an IMAGE script
    - Just copy and paste the link given at the end of the tutorial. Like this, but with different code:
    "http://free.jbuc.com/weatherIm..."
    *(repeat of jbuc's link posting)
  • 814110885
    It's really awesome, but can you show more specific how to get the weather image to work?
  • YinYangGreen
    do you know how to get your computer hardware temperature in fahrenheit? here is a site that shows you how to get it with Celsius, which i have, but i like fahrenheit more.
  • YinYangGreen
  • Fat_monkey6
    I couldn't change the url for current weather conditions. Also, the current weather image code that you've provide doesn't work :(
  • theo de la tore
    can you please post the link of your desktop wallpaper please?
    thnx
  • A small guide to the php icon script:
    https://gist.github.com/120974...

    1. Download script
    2. Go to http://weather.yahoo.com
    3. Search you city/town
    4. Copy url from address bar
    5. Paste url in script (line 2)
    6. upload script to server running php
    7. GeekTool->image->http://yourdomain.tld/path/to/script.php

    Enjoy!
  • Javier
    How can I find my city data code? Is it the number at the end of the URL?
  • jbuc
    here's how to find the code... with pictures.
    http://free.jbuc.com/weatherIm...
  • ManyQuestions
    I cannot get the weather image working. Can you post your whole command so all that i have to change is the weather code from yahoo? Thanks
  • jbuc
    that php code messed up when I posted it...  here's a plain text version.

    http://free.jbuc.com/weatherIm...
  • thedesertfox03
    I copy/pasted the exact code with my citydata subbing in where it needed to go. My forecast works but I can't get the image working. If I've done no customization or anything to my Mac, don't have a server, or anything special other than other Geektools working on my Mac, what's my next move?

    This is what I used in the shell command box:

    /* Be Sure to replace CITYDATA in $url with your own city from Yahoo */
    include('simple_html_dom.php');
    if($_GET['city']){
    $city = $_GET['city'];
    }
    $url='http://free.jbuc.com/weatherIm...
    $html = file_get_html($url);

    $es = $html->find('.forecast-icon',0)->getAttribute('style');
    preg_match('/http:(.*?)png/', $es, $imagepath);

    $image=imagecreatefrompng($imagepath[0]);


    imagealphablending($image, true);
    imagesavealpha($image, true);
    header('Content-Type: image/png');
    imagepng($image);

    ?>
  • jbuc
    with php you can use the following (i'm using simple_html_dom.php as well which is  overkill, but it works): 
    find('.forecast-icon',0)->getAttribute('style');preg_match('/http:(.*?)png/', $es, $imagepath);$image=imagecreatefrompng($imagepath[0]);imagealphablending($image, true);imagesavealpha($image, true);header('Content-Type: image/png');imagepng($image);?>

    http://simplehtmldom.sourcefor...
    direct download: http://sourceforge.net/project...

    or, if you want. I already have it setup... just use this path for the image address like I mentioned above.
    http://free.jbuc.com/weatherIm...<citycode></citycode>
  • MandyFresh
    Where do you find the "CITYDATA" info on the yahoo site?  I searched and found my City however I am not sure what info to copy and paste into this section on Geektool.
    Please advise.
  • Oliviermougin
    Hi,
    very good idea and beautiful innovation. For sure you can be proud of your work done .
    for myself, I've set your php script in perl. but i was wondering.. Where to put the script in geektool ?

    (if you want the perl script i post it there )

    #!/usr/bin/perl -w
    use LWP::Protocol::http;
    use HTTP::Status;
    use LWP::Simple;
    use URI::URL;
    use strict ;



    my $url="http://weather.yahoo.com/franc... " ;
     #as well as in php, replace yourcitydata by the exact position .. the extension unit=c comes from the fact by defautlt yahoo give temperature in F, as i am in europe, i do prefer celsius :-)

    my $pageToAnalyse =get($url);

    my $longueurPage=length $pageToAnalyse ;
    my $startDelimiter='="forecast-icon" style="background:url(' ;
    my $offsetDelimiter=length ($startDelimiter);

    my $endDelimiter='); _background-image/* */: none; ';
    my $startFound = index $pageToAnalyse , $startDelimiter ;
    my $endFound = index $pageToAnalyse , $endDelimiter ;
    my $longueurToExtract = $endFound - $startFound ;
    my $urlPicture = substr $pageToAnalyse , $startFound+$offsetDelimiter+1, $longueurToExtract-41 ;
    print " $urlPicture \n" ;
    =========================================

  • tablesideEMU
    Hey looks great

    I've been trying to get the weather bit to work for accuweather.com but i can't get it to work

    All I can think to do is change the url in qutoes to the url of the accuweather page.
    "http://www.accuweather.com/en-..."
    But nothing happens after doing that.

    Any ideas? I'm very new to all this code.
  • Davindc
    could you post a tutorial on the part for displaying the image of the weather? i don't really understand what your saying..
  • Aaron Hauge
    I cannot get the weather portion to work, which portion of the url is the citydata we are supposed to replace
  • BL
    the weather conditions doesnt fork for me. i have the new geektool
  • The weather icon PHP script is not working. I know that this is an old post, but if someone is interested in a working php script you can download it here https://gist.github.com/120974...
  • Sean
    $url = "http://weather.yahoo.com/forec...";
    $buf = file_get_contents($url);
    if (preg_match('/<div class="forecast-icon" style="background:url\(\'(.*?)\'\); _background\-image/', $buf, $m)) {&lt;br&gt;        $image = imagecreatefrompng($m[1]);&lt;br&gt;        imagealphablending($image, true);&lt;br&gt;        imagesavealpha($image, true);&lt;br&gt;&lt;br&gt;        header('Content-Type: image/png');&lt;br&gt;        imagepng($image);&lt;br&gt;}"></div>
  • Alexander
    Thanks for curious guide!
    If it still matters, I've rewritten shell command for uptime, now It's more compact:
    uptime | perl -pe 's/.*(( [0-9]+ mins),|( [0-9]+:[0-9]+,)|(( [0-9]+ hrs),)).*/Uptime.$2$3$5/g' | sed -e 's/:/ h /' -e 's/mins/min/' -e 's/,/ min/' -e 's/hrs/h/'
    Uptime days are omitted.
  • iPortable
    I have figured out how to fix the "2min1", but you have to test it with days. And I have problems with full hours "1h," (if you can give me the output string of 1 hour and one of many days I can fix it too)

    write this after the first $5 appearance:
    sub(/[0-9]/, "", $5);
  • iPortable
    and you will need sub("secs,", "secs", $4); to get rid of "42secs,"
  • Zfrench
    hey i was wondering if you could tell me what the code would be for current weather temperature in salt lake city utah. i tried following your instructions and just couldn't figure it out
  • Jacob
    this should work.
    http://weather.yahoo.com/forec...

    USUT0225 is the code
  • zach
    i can't figure out the weather image thing
  • Excellent write up! Your instructions here were easy to follow and were great at explaining what was going on. As a beginner with the tool this was a big help! Thank you!
  • Shibby!
  • James
    can anybody update this now? im having trouble with this STILL...any help would be greatly appreciated thanx
  • jbuc
    I have posted a version to my site that will let you put your city information in as a variable...
    I really only needed it for me, but if it helps you feel free to use it. Though, I can't guarantee it will always stay - so if you need help later send me an email or something.

    http://free.jbuc.com/weatherIm...
    would give you the icon for Boise Idaho. I ended up using a different method than described above because I don't think I have the CURL package installed or something.. Honestly I didn't feel like looking into it.


    To get your code:
    "enter weather.yahoo.com search for the place you want, then press the "RSS" button which will set you up with a webside with all sort of text that most likely wont make sence, that you dont have to worry about..
    For "Stavanger Norway" the adress would be "http://weather.yahooapis.com/f... the part you need to copy is "NOXX0035&u=f" remember to make the F into a C if you want Celsius instead of Fahrenheit"
    (copied straight from http://answers.yahoo.com/quest... )




  • Talha_13
    also note that even if i paste the url in the wb browser... it doesn't pull any image
  • Iamawesome
    Talha_13 I'm seeing it on my desktop at the moment. would you mind posting the code you are trying to use and I can see what's happening. I might need to change the search for non-USA regions
  • Talha_13
    http://free.jbuc.com/weatherIm...

    it starts working... just like right now it is... but after 10 min the pic disappears :(
  • Talha_13
    Hi jbuc.... this started to work great but the image disappears after the first refresh.... i don't know why :(

    can u help me get for singapore... i hv no idea what this php stuff is.... can u give me a simple url that if i paste in image will get me the image.... pl!!!!
  • jbuc
    that was me (jbuc) btw I just messed up in how I was posting.
  • Josh
    Just wanted to say thanks for the weather script. Lifehacker recently posted something about this, but not nearly as awesome as the image one you have here!
  • Sifarworks
    awesome php script for the weather image..! Thanks a lot.
  • SOLUTION for all your weather image problems.
    Clearly, Yahoo weather URLS look a little different.
    Go to their homepage, type in your city/zip,
    and then use THAT url instead of the /forecast/CITYID url. EVERYTHING else can be the same.

    mine, for pittsburgh, is here: technoheads.org/weatherimage.p...
  • Tanaciousp
    awesome, thanks! glad to see some fellow geeks from the burgh!
  • Ron Smith
    Awesome! Inspired me to make this: http://www.therealmacgenius.co...
  • Trying to get the weather working in New Zealand, but when i navigate to my page, i get http://nz.weather.yahoo.com/au... which is not in the same format at all... what url do i use? Thanks
  • Hallooo
    you have to go into the RSS feed of it.
  • Aaron
    I am a bit confused, do u need a server to upload your php file to so that it can run and get this image for you?
  • Erik
    how do u get the weather image to appear? as in, how do u have that PHP automatically run and refresh
  • endless
    hey

    I gotta say, this is pretty cool...and tnx for everything here..

    I wanted to put weather on my MBP cuz its on the move all the time and I gotta know what kind of weather it is in my town back at home..

    but there is the problem...

    Im a php and script r-tard so if you would be so nice and wrote a script for weather and image for my home town LJUBLJANA ( http://weather.yahoo.com/slove... ) and send it to me via mail ..

    ercvider@gmail.com

    I would be too grateful .. also u can check out my DA account if you will find anything usefull there... ( http://endless13.deviantart.co... )

    tnx alot..

    e
  • Ollebro
    i use this uptime code and it works well as long the computer have been up more than 1 hour, before that it only shows the minutes but withhout the min text.

    uptime | awk '{sub(":", "h ", $3); sub(",", "min", $3); print "Uptime: " $3}'
  • yehhit
    why don't you paste the code for the php correctly as it's not formatted on the page?
  • Geronimo Gutierrez
    This article is great!
    One thing to help the ones that have the weather image problem...

    I found this: http://bugs.php.net/bug.php?id...

    So maybe you need to type the url (that is inside of the php code) on a web browser (with your city info). That url is redirected to another yahoo url.

    Copy and paste that one on your php code and upload the .php file again to the server. It should work!
  • Thank you for inspiring article :)
    Your and the help from the comments produced this..

    http://www.flickr.com/photos/v... :)
  • robbyS
    So glad I stumbled on your website, this geektool walkthrough you have right here helped me out a lot.

    Also, what do I need to download/buy in order to have the license to that wallpaper?
  • The image is from the Riot Gear pack available from Video Copilot. It may also be available in Evolutions, I don't remember.

    http://www.videocopilot.net/pr...

    (Warning, video on that page starts playing immediately.)
  • robbyS
    Sweet, you are awesome!
  • toras
    pleeeease share your wallpaper)
  • Unfortunately, I can't. The image used as my wallpaper came from a stock image set and the license forbids me from re-distributing.
  • ajvw
    NEW DEVELOPMENT. I have found a new way to throw up the weather forecast icon on your desktop without any php.

    curl --silent "http://weather.yahoo.com/forec..." | grep "forecast-icon" | sed "s/.*background\:url(\'\(.*\)\')\;\ _background.*/\1/" | xargs curl --silent -o /weather.png

    set that as one shell script, this pulls the forcast icon down onto your computer and saves it in your rot directory, feel free to change the directory by changing the /weather.png

    then

    file://localhost/weather.png

    set this in an image in geektools, place where you want, set your refresh rate on BOTH THE SCRIPT AND PICTURE

    this was not my idea, i got it off another user (http://pastie.org/private/alab...
  • ivan_gt
    It doesn't work for me. Are there any prerequisites for this (something I need installed)?

    I = n00b
  • rev82
    A somewhat messy fix for the odd uptime output seen before the one hour mark;

    myminchk=`uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print $4}'`
    if [ "$myminchk" == "min" ]
    then
    uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print $3$4}'
    else
    uptime | awk '{sub(/[0-9]|user\,|users\,|load/, "", $6); sub(/mins,|min,/, "min", $6); sub(/user\,|users\,/, "", $5); sub(",", "min", $5); sub(":", "h ", $5); sub(/[0-9]/, "", $4); sub(/day,/, " day ", $4); sub(/days,/, " days ", $4); sub(/mins,|min,/, "min", $4); sub("hrs,", "h", $4); sub(":", "h ", $3); sub(",", "min", $3); print $3$4$5$6}'
    fi

    Not at all efficient, but it does work.
  • ajvw
    Oh, and this was the code Copied and pasted from the Text file linked above containing the PHP code, with a changed City code.
  • ajvw
    Hey guys, having some issues with the final (and hardest) one, the weather image. i am trying to host the file on a free online php server. (its what i can do)

    i upload the file blah blah blah, but when i open the file i get

    "Parse error: syntax error, unexpected T_STRING in /www/110mb.com/a/j/v/w/_/_/_/_/ajvw... on line 14"

    now my username is ajvw. anyone have any insight on this?

    i am a total PHP nooblet,

    thanks guys

    ajvw
  • hendo13
    I had this working for quite some time but now all of a sudden, it disappeared, and will not work anymore. Anyone else having this problem?
  • If anyone doesnt want to host that php file, I have one for pittsburgh users;
    http://technoheads.org/weather...

    It might go down shortly this weekend, but afterwards it should be up for a while.

    Cheers,
    Salem
  • Avi
    Fatal error: Call to undefined function imagecreatefrompng() in /Users/myusername/Sites/weatherimage.php on line 21



    This is the error I get when trying to load your php... I've edited it with the proper forecast information....
  • Avi
    The reason any error like this happens I've realized is because leopard does not have php installed by default... simply installing php won't fix this but you also must install the gd library. Once I did this everything worked out fine. I used this website to make the process super easy:

    http://phildawson.tumblr.com/p...

    Its 5 commands (including the download) and its all done in terminal. Error free now. Thanks for the script!
  • Emeraldscorpion
    Where did you upload your php script to?
  • The script must be on a server running PHP, though if you have PHP installed on your Mac, you can actually put the script in your sites folder and turn on web sharing.
  • Emeraldscorpion
    Actually there's another simpler way for displaying the weather image. Since Geektool is for Mac, i'm assuming you all have Safari. Go to the weather.yahoo.com page, find your area etc, then right-click on the image and select "Inspect Element". A new window will pop up. Select Images from the sidebar on the left and scroll down until you find the weather image(Actually for me it was the first one). Hover over it in the sidebar and a url will pop up. Unfortunately, there's no way to copy it so you will have to type it manually. When you finish typing, hit enter and you should see the image there. Copy the image URL and put in in Geektool as a picture and you're done!
    Although, I only just discovered this by myself a few hours ago, so it might not work for you, but it works for me!

    EDIT: Actually, it turns out that it doesn't change after the weather does. Sorry!
  • Vincent
    These scripts are great especially the php weather image. Can be a bit tricky to get to work but this is how I did it. First off, renaming the textfile to .php using the GUI on my Mac did not seem to work--kept appending the filename with .txt Renaming in the terminal window worked. After that, I uploaded it to my server and referenced it as a photo in my geektool. Alas, this alone was not enough--seems the actual address is not what you might think (i.e. it is not YOURSERVER.COM/weatherimage.php. Rather, it would appear that some hosting services, like mine add a bit more to the URL. If you can see the image by doubleclicking on the php file on your server (will come up in a webpage), you can get the correct address to use and...voila, very cool weather image on your desktop.
  • Mythbastard
    It don't work for me. Help please!!!!
  • Helpful
    If the PHP script isn't working for you maybe you need to activate CURL (curl.so) on your server. Do a Google search or ask your server admin.
  • MK
    I'm having a bit of trouble with the graphic weather display. For some reason I keep getting a fatal error: Call to undefined function imagecreatefrompng() in [location of file] on line 21.

    Any idea what could be causing that? I love the look of your display and really want to re-do my desktop with it.
  • The only thing I can think of is that you don't have the proper image libraries installed on your server. What version of PHP are you running?
  • montgomerywilliams
    I'm having the same problem. Im running the one that comes standard on the new Leopard OS, but i don't know which version that is.

    The exact error message is:

    Fatal error: Call to undefined function imagecreatefrompng() in /Users/myusername/Sites/script.php on line 19
  • After digging into it, it sounds like GD library is not installed. I'm not a heavy coder, but here's info on the GD library including how to install and configure. I was just lucky in that my hosting company (Dreamhost) already has this pre-installed.

    http://us3.php.net/manual/en/b...
  • Andrew
    you can use my file that i FINALLY got to work after some tweaking

    http://www.exponentiallyfabulo...
  • Mythbastard
    It don't work for me. Please, how's your whole php code in your weatherimage.php archive in http://www.exponentiallyfabulo... Please, to change the city code only...
  • I just visited that URL and an image came up with no errors.
  • Fré
    I only see the image... not the code. Unfortunately it's the code I need :s
  • Johnny
    This is amazing! Your PHP work blew me away. I can't seem to get it to work on my end though. I changed "CITYDATA" to "CAXX0504" (which is Toronto) and uploaded the PHP to my server here: http://www.johnnylarocque.com/...

    But it doesn't output usable data. Any idea how I can fix this?
  • Geronimo Gutierrez
    I found this: http://bugs.php.net/bug.php?id...

    So maybe you need to type the url with CAXX0504 in your browser and then copy the url that yahoo redirects yo to. And put that one instead of the other.
    It works for me...
  • Mike
    How can i get Celsius instead Farentheit? Thanks
  • adilvaz
    I m having trouble with this too. I tried changing the &u=f to &u=c, immediately after the city code in the script, but then nothing shows. Turning it back to f shows the Fahrenheit temp as it should. Any suggestions ?
  • mashimero
    You do have to change the &u=f to &u=c but you also have to change the F to a C where it says:

    (Current Conditions:|F
  • adilvaz
    Thank you ! It is working now.

    Adil

    Em 25/07/2009, às 23:51, Disqus escreveu:
  • Big fat arse
    the fact that the pic shows april 1st should be a clue to you all..
  • Gavin
    hey can someone help me with this? I'm using the script in the image section of my geektools. using the file:// form to point to the php file. Yet when I do it, nothing ever shows up.
  • Sorry for the late reply. The file:/// syntax only returns file contents, the script is never executed. The file needs to live on a server (either remote or local) running PHP (with the GD library), and accessed using the http:// syntax.
  • Jason
    Guys, I'd strongly recommend doing the php stuff with something that doesn't require you to run a local web server, that's some seriously redundant overhead. As an alternative try Python, Ruby or Perl. They are all installed on your mac when it's clean and a script just needs to have...

    #!/usr/bin/env python

    #!/usr/bin/env ruby

    or

    #!/usr/bin/env perl

    at the start...

    Doing web scrapes with all of those is also IMHO better.

    Also, sed, awk and cut, can make very fast work of simple web scrape operations.

    YMMV of course.
  • Chris
    Ditto - grabbed the script and change my city name. Should I have to do anything else?

    Thanks!
  • mjc
    Awesome ideas. unfortunately your smartquotes ruin a lot of the scripts and I had to do some regexps with textmate to clean them up. your blog shouldn't be transcribing quotes inside of a CODE tag into smart quotes. might want to investigate!
  • Samuel Harrison
    i have to say, your setup is awesome!

    the one problem is that, to get it working, you have to... well, know what youre doing (it is supposed to be GEEKTOOL, i know, but some of the things you can do are just too cool for us non-geeks to pass up xP).

    do you think you might be able to go into more detail on how to call the scripts through GT and also what extensions the files should have when you save them etc...? it would be really helpful.

    thanks!
  • If you're referring to the PHP script, it should be saved as .php and reside on a server with PHP (or your own system if you have it installed, which I'm not sure Macs do by default). Then it _should_ be a simple matter of putting the address to the PHP script (eg http://yourserver.com/path/to/... in the image URL field in GeekTool.

    If you're referring to the other scripts, those should sit in the command section of the Shell in GeekTool. Let me know if you have problems or need more help.


    EDIT: I've updated the post to include text files of the commands which should be clean.
  • Samuel Harrison
    alright, it makes sense to me now. thanks!
  • Samuel Harrison
    oh, one more thing, though.

    when i use the provided script to display my ip's, i end up getting:

    â(ip1)â`
    â(ip2)â
    â(ip3)â

    instead of the nice, neat display in your screenshot... any ideas?
  • The only thing I can think of is to remove the quotes around the $myen0, $myen1, and $wip in the echo statements.
  • Phillip Mengell
    Hey man,

    Can you show me your actual PHP? I have been messing with this for the past two days (I have no PHP knowledge, so I can't beat this line 4 syntax error!). Thanks!
  • Can you post the actual error your getting? I'll see what I can do.

    EDIT: I've updated the post to include text files of the commands which should be clean.
blog comments powered by Disqus