Originally Posted by
Faud
I would like to add a simple text weather to the right of my screen but dont really know where to start. I have read some posts about making a scripts folder and adding a weather file with some info that I get from weather.com but I havent found a real "starting place" if someone could point the way.
Thank you much. Screenshot below
Faud
Hi Faud
How about one like this attachment below? Of course you can edit out what you don't want.
We'll do this in 7 easy steps.
To keep you're original conky setup you'll need three more files.
1: conkyweather (save in: ~/.conkyscripts)
2: weather.sh (save in: ~/scripts)
3: weather.xslt (save in: ~/scripts)
Files 2 and 3 must be in the same folder (~/scripts).
You'll have 2 conky scripts as well, the one you have now, which I will have you move & rename, and conkyweather as seen in #1 above. Put both of these files in ~/.conkyscripts
STEP 1: conkyweather ( a conky script file )
Create conkyweather file:
Code:
gedit ~/.conkyscripts/conkyweather
Here is my conkyweather file, copy and paste it to the empty file you have created above with gedit, then Save: conkyweather
Code:
background yes
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
double_buffer yes
use_spacer yes
use_xft yes
xftfont Candara:size=8
xftalpha 0.5
update_interval 1.0
draw_shades no
draw_outline no # amplifies text if yes
draw_borders no
uppercase no # set to yes if you want all text to be in uppercase
stippled_borders 3
border_margin 9
border_width 10
default_color white
own_window_colour brown
own_window_transparent yes
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
gap_x 10
gap_y 25
# Subtract file system buffers from used memory?
no_buffers yes
TEXT
${color cyan}WEATHER: ${hr 1}$color
${color white}${execi 60 ~/scripts/weather.sh ARBA0009}$color
STEP 1a - See Step 6: You will need to change ARBA0009 for your ZIP Code if in the US or City Code if outside the US.
ARBA0009 = Buenos Aires Argentina.
NOTE: At this time "move" (or copy) your existing conky file into the same folder as conkyweather and RENAME it to : conkymain You'll see why in STEP 4
STEP 2: weather.sh (save in: ~/scripts)
Here is my conkyweather.sh file:
Code:
#!/bin/sh
#
# Grab weather data from weather.com and format it according to the given XSLT
# Script written by boojit
# Modified by Hellf[i]re
# Modified by Vredfreak
# The orignal script and xslt can be downloaded from http://pondol.com/weather.tar.gz
# Usage:
# ${execi 1800 /path/to/weather/weather.sh location}
# Usage Example:
# ${execi 1800 /home/user/weather/weather.sh 038
~[My Deviantart Page]33}
# your Location ID: use http://xoap.weather.com/search/search?where=[yourcity] to find it
# U.S. users can just use their zip code; doubt that works for anyone else though (YMMV)
LOCID=ARBA0009
# s=standard units, m=metric units
UNITS=m
# where this script and the XSLT lives#
RUNDIR=~/scripts
# there's probably other stuff besides CURL that will work for this, but i haven't
# tried any others.
# you can get curl at http://curl.haxx.se/
CURLCMD=/usr/bin/curl
# get it at http://xmlsoft.org/XSLT/
XSLTCMD=/usr/bin/xsltproc
# you probably don't need to modify anything below this point....
# CURL url. Use cc=* for current forecast or dayf=10 to get a multi-day forecast
CURLURL="http://xoap.weather.com/weather/local/$LOCID?dayf=10&unit=$UNITS&cc=*"
# The XSLT to use when translating the response from weather.com
# You can modify this xslt to your liking
XSLT=$RUNDIR/weather.xslt
#filter (if you want to convert stuff to lower-case or upper case or something)
#FILTER="|gawk '{print(tolower(\$0));}'"
#####
eval "$CURLCMD \"$CURLURL\" 2>/dev/null| $XSLTCMD $XSLT - $FILTER"
STEP 2a - See STEP 6: Once again you'll need to edit two lines:
LOCID=ARBA0009 <-- to ZIP or City Code
# s=standard units, m=metric units
UNITS=m <-- to s for 23°F m= 23°C
It is already set for the top-right of your screen.
Once that's set up you need to make it executable:
Code:
chmod a+x ~/scripts/weather.sh
STEP 3: weather.xslt (save in: ~/scripts)
This is the coding responsible for the formatting you see in the image below.
Code:
<!--
This XSLT is used to translate an XML response from the weather.com
XML API.
You can format this file to your liking. Two things you may feel
like doing:
1) Modify the layout of the fields or static text already defined
2) Add other fields from the XML response file that aren't referenced in this
XSLT. You can grab a full list by just doing a:
wget "http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS"
(change $LOCID and $UNITS to suit your needs)
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="text" disable-output-escaping="yes"/>
<xsl:template match="weather">
<xsl:apply-templates select="loc"/>
<xsl:apply-templates select="cc"/>
<xsl:apply-templates select="dayf/day[@d='1']"/>
</xsl:template>
<xsl:template match="loc">
<xsl:text>Live from: </xsl:text><xsl:value-of select="dnam"/>
<xsl:text>
Lat: </xsl:text><xsl:value-of select="lat"/>
<xsl:text> Long: </xsl:text><xsl:value-of select="lon"/>
<xsl:text>
SUN: Rise: </xsl:text><xsl:value-of select="sunr"/>
<xsl:text> Set: </xsl:text><xsl:value-of select="suns"/>
</xsl:template>
<xsl:template match="cc">#
<xsl:text>
Temp: </xsl:text><xsl:value-of select="tmp"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text> Feels Like: </xsl:text><xsl:value-of select="flik"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text>
Conditions: </xsl:text><xsl:value-of select="t"/>
<xsl:text>
Visibility: </xsl:text><xsl:value-of select="vis"/><xsl:text> KM</xsl:text>
<xsl:text> Humidity: </xsl:text><xsl:value-of select="hmid"/><xsl:text>%</xsl:text>
<xsl:text>
Wind: </xsl:text>
<xsl:choose>
<xsl:when test="wind/s = 'calm'"><xsl:text>0</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="wind/s"/></xsl:otherwise>
</xsl:choose>
<xsl:value-of select="/weather/head/us"/>
<xsl:choose>
<xsl:when test="wind/s = 'calm'"><xsl:text>(0 km/h)</xsl:text></xsl:when>
<xsl:otherwise><xsl:text> (</xsl:text><xsl:value-of select="round(wind/s * 0.6214)"/><xsl:text> mph)</xsl:text></xsl:otherwise>
</xsl:choose>
<xsl:text> (</xsl:text><xsl:value-of select="wind/t"/>
<xsl:text>)</xsl:text>
<xsl:text>
Bar Pressure: </xsl:text><xsl:value-of select="bar/r"/>
<xsl:text> ~ </xsl:text><xsl:value-of select="bar/d"/>
<xsl:text>
UV: </xsl:text><xsl:value-of select="uv/i"/>
<xsl:text> ~ </xsl:text><xsl:value-of select="uv/t"/>
<xsl:text> Dew Point: </xsl:text><xsl:value-of select="dewp"/>
<xsl:text>
MOON: Icon: </xsl:text><xsl:value-of select="moon/icon"/>
<xsl:text> ~ </xsl:text><xsl:value-of select="moon/t"/>
</xsl:template>
<xsl:template match="dayf/day[@d='1']">
<xsl:text>
Tomorrow: </xsl:text><xsl:value-of select="low"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text> to </xsl:text><xsl:value-of select="hi"/><xsl:value-of select="/weather/head/ut"/>
<xsl:text> ~ </xsl:text><xsl:value-of select="part[@p='d']/t"/>
<xsl:text>
</xsl:text><xsl:value-of select="/weather/swa/a/t"/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
So now you have four files:
~/scripts
conkyweather.sh (executable)
weather.xslt
and
~/.conkyscripts
conkymain
conkyweather
STEP 4: Creating a way to start both conkys:
Start by creating a hidden file startconky
Code:
gedit ~/.startconky
Copy and past this code into that file and save it:
Code:
#!/bin/bash
sleep 25
conky -c ~/.conkyscripts/conkymain &
sleep 1
conky -c ~/.conkyscripts/conkyweather &
The sleep command allows your desktop to setup before conky runs.
STEP 6: Getting more information
Go to this URL (Copy and past it to your browser): (change the city name or use your ZIP Code once online, it's the easiest way)
Code:
http://xoap.weather.com/search/search?where=Buenos Aires
Will give you information like this:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--This document is intended only for use by authorized licensees of The Weather Channel. Unauthorized use is prohibited. Copyright 1995-2005, The Weather Channel Interactive, Inc. All Rights Reserved.-->
<search ver="2.0">
<loc id="ARDF0127" type="1">Aeroparque Buenos Aires, Argentina</loc>
<loc id="ARBA0009" type="1">Buenos Aires, Argentina</loc>
</search>
As you see I have two choices for Buenos Aires.
Next do this in Terminal:
Code:
wget "http://xoap.weather.com/weather/local/ARDF0127?cc=*&unit=m"
Changing ARDF0127 for an option you got at the URL above and if necessary:
unit=$s for standard (F)
unit=$m is for metric (C)
You will receive a file something like this in your home folder: ARDF0127%3Fcc=*&unit=m
Open this and see something like:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--This document is intended only for use by authorized licensees of The Weather Channel. Unauthorized use is prohibited. Copyright 1995-2005, The Weather Channel Interactive, Inc. All Rights Reserved.-->
<weather ver="2.0">
<head>
<locale>en_US</locale>
<form>MEDIUM</form>
<ut>C</ut>
<ud>km</ud>
<us>km/h</us>
<up>mb</up>
<ur>mm</ur>
</head>
<loc id="ARDF0127">
<dnam>Aeroparque Buenos Aires, Argentina</dnam>
<tm>5:43 PM</tm>
<lat>-34.58</lat>
<lon>-58.43</lon>
<sunr>5:42 AM</sunr>
<suns>8:09 PM</suns>
<zone>-3</zone>
</loc>
<cc>
<lsup>12/29/07 5:00 PM Local Time</lsup>
<obst>Buenos Aires Air Park, Argentina</obst>
<tmp>29</tmp>
<flik>30</flik>
<t>Partly Cloudy</t>
<icon>30</icon>
<bar>
<r>1003.0</r>
<d>falling</d>
</bar>
<wind>
<s>8</s>
<gust>N/A</gust>
<d>270</d>
<t>W</t>
</wind>
<hmid>51</hmid>
<vis>10.0</vis>
<uv>
<i>3</i>
<t>Moderate</t>
</uv>
<dewp>18</dewp>
<moon>
<icon>20</icon>
<t>Waning Gibbous</t>
</moon>
</cc>
</weather>
This file gives you the coding necessary to edit weather.xslt the way you want.
STEP 7: Starting and Stopping both conkys:
STEP 7a: Automatically at bootup
I have Feisty, if you don't the process may be different:
Open: Systems>Preferences>Sessions>New
Name: Conky
Command: /home/your_log_in_name_here/.startconky
NOTE: If you already have conky starting automatically edit it to reflect the above command with the appropriate change.
STEP 7b: Manually:
In Terminal:
Starting both conkys: (See STEP 4)
Stopping both Conkys
I think that's it.
If you have any more questions, just ask.
Bruce
PS: This information is brought to you by all the people here that helped me setup my conky. If it wasn't for them I could not have answered this request.
EDIT: 21 Jan 2008: Two errors in weather.sh corrected - My Thanks to aonegodman
EDIT: 22 Jan 2008: Edited "~/.startconky" - Thanks to Salpiche
EDIT: 20 Feb 2008 - Edited wget command
EDIT: 08 Mar 2008 - Edited: Don't need gksudo in home folder.
Bookmarks