Get your conky location aware

2010-02-19-225826_188x44_scrot

Add this in your conkyrc

${exec curl -s "http://api.hostip.info" | xpath -e "//gml:featureMember/Hostip/gml:name/text()" -q} ${exec curl -s "http://api.hostip.info" | xpath -e "//gml:featureMember/Hostip//gml:coordinates/text()" -q}

Hostip is well known as a service provider of the geoclue framework. It translates IP address to geolocation information. The API we use will return a GML document like

<?xml version="1.0" encoding="ISO-8859-1" ?>
<hostipLookupResultSet version="1.0.1" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.hostip.info/api/hostip-1.0.1.xsd">
 <gml:description>This is the Hostip Lookup Service</gml:description>
 <gml:name>hostip</gml:name>
 <gml:boundedBy>
  <gml:Null>inapplicable</gml:Null>
 </gml:boundedBy>
 <gml:featureMember>
  <hostip>
   <ip>58.212.88.212</ip>
   <gml:name>Nanjing</gml:name>
   <countryName>CHINA</countryName>
   <countryAbbrev>CN</countryAbbrev>
   <!-- Co-ordinates are available as lng,lat -->
   <ipLocation>
    <gml:pointProperty>
     <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
      <gml:coordinates>118.883,32.05</gml:coordinates>
     </gml:Point>
    </gml:pointProperty>
   </ipLocation>
  </hostip>
 </gml:featureMember>
</hostipLookupResultSet>

Because it uses ip to lookup your address, you cannot expect higher resolution and precision currently.