0

I am editing my question for clarification... I am sorry for any confusion... The Conky syntax has changed with the latest version (I assumed users of the latest version of Conky was aware of that).

My Problem Clarified:

I create an xml file that takes weather information from Wunderground.com.

I would prefer to find a simple way to extract specific information out of the xml file to display in Conky (including the weather icon).

Most information I have found so far does not do what I need, and I can't cobble together my own solution from what I have found because the information seems needlessly complex. I want the method used to not require a lot of extra programs and/or scripting gymnastics.

Example:

  1. I use "curl -s http://api.wunderground.com/api/[key]/conditions/q/TX/[mycity].xml -o ~/path/weather.xml" to create my xml file using Wunderground.com.

  2. Within the xml file is the path to the current weather's icon (Let us say: "http://icons.wxug.com/i/c/k/cloudy.gif")

  3. Within the xml file is specific data I want to display, such as the current temperature (the xml files shows '<'temp_f'>'68.9'<'/temp_f'>'"... Note: I am using '<' otherwise my post won't show the tag). Therefore, I would like to take the 68.9 and display it (or round it to 69).

In the end, using the example above, my Conky would then show a "Cloudy" Icon, and 69F (or 68.9F). I could then (easily I hope) extract and display other information in a similar fashion.

Thank you in advance for any help you can offer.

  • 1
    We are not actually aware.... – Ramhound Sep 27 '17 at 22:39
  • Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. – Ramhound Sep 27 '17 at 22:41
  • I found an answer to part of my question. To extract the specific information I want, I simply do as follows: curl api.wunderground.com/api/[key]/conditions/q/TX/[mycity].xml | awk -F'[<|>]' '/<temp_f>/ {print "Current Temperature:"$3}/<windchill_f>/ {print "Windchill:"$3}' – Curtis Oct 8 '17 at 2:21
  • I now need an answer to the other part of my question... how do I get conky to display the current weather icon from the url found in the tag '<icon_url>'. The url will change as the weather changes. – Curtis Oct 8 '17 at 2:25
1

Part 1:

In order to extract the information directly from the web url you would use the following command:

curl api.wunderground.com/api/[key]/conditions/q/[state]/[mycity].xml | awk -F'[<|>]' '/<temp_f>/ {print "Current Temperature:"$3"°F"}/<windchill_f>/ {print "Windchill:"$3"°F"}'

...or, alternately, you can extract the information from a downloaded xml file:

curl 'file:///home/path/weather.xml' | awk -F'[<|>]' '/<temp_f>/ {print "Current Temperature:"$3"°F"}/<windchill_f>/ {print "Windchill:"$3"°F"}'

You can replace

'/<temp_f>/' {print "Current Temperature:"$3"°F"}

with any other tag and information you want to display.

Part 2:

In order to extract the icon url and then get the icon to display in Conky, you would need to extract the url to a file as follows:

curl api.wunderground.com/api/[key]/conditions/q/[state]/[mycity].xml | awk -F'[<|>]' '/<icon_url>/ {print $3}' >~/path/image

You then need to download the icon, give it a generic name, and then move it to the folder you desire:

wget -O weather.gif -i ~/path/image

mv ~/weather.gif ~/path/

Create a sh script (we'll call it "weather.sh") with the above steps, and place it where you desire.

You would then place commands in your ".conkyrc" along the lines of:

${execi 300 sh ~/path/weather.sh}

${image ~/path/weather.gif -p 10,40 -s 32x32}

In the "image" command, "-p" = the position and "-s" = the pixel size of the image. Change the coordinates and size to suit your purpose.

This should be a lot simpler than many of the weather scripts, etc. that I have found for Conky.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.