Results 1 to 9 of 9

Thread: Conky weather font rendering help

  1. #1

    Default Conky weather font rendering help

    Alright, here is my issue:

    I wrote a conky weather getting script using python to fetch xmms feeds from the NWS. Everything about it works well, but I have yet to implement an extended forecast.

    I then went to the trouble of creating my own weather script using inkscape and, at first FontForge (which is usually buggy, but somehow extremely buggy on openSUSE), and then after this didn't work...I created an Inkscape font from the same glyphs and used an online converter to convert it into a TTF. The issue is that I can use this TTF font in Libre Office, and view it using the TTF viewer without a problem, however when I ask conky to render it it gives me normal text letters. Why?

    I have run fc-cache -v -f several times, and another font of mine (created back when I was using Ubuntu+FontForge) renders fine. I'm attaching the TTF so that other can help debug. The letters of interest are all caps: STORCP (for sunny, tstorms, snow, rain, cloudy, and partly-cloudy).

    Thanks for the help and enjoy the font if you can (I'll be adding on to it for a few more conditions when I come across them. FYI. I'll post the scripts when I am done bug checking the long term forecast)

    https://docs.google.com/open?id=0ByY...E4yeGRCQXI2dnc

  2. #2

    Default Re: Conky weather font rendering help

    Quote Originally Posted by gforce6point0 View Post
    Alright, here is my issue:
    I wrote a conky weather getting script using python to fetch xmms feeds from the NWS. Everything about it works well, but I have yet to implement an extended forecast.
    In case you'd like to take a look at it, I wrote a conkyweater too. It gets installed together with conkyconf. Both scripts are available in my repo:
    http://forums.opensuse.org/english/g...ml#post2487092


    Quote Originally Posted by gforce6point0 View Post
    I then went to the trouble of creating my own weather script using inkscape and, at first FontForge (which is usually buggy, but somehow extremely buggy on openSUSE), and then after this didn't work...I created an Inkscape font from the same glyphs and used an online converter to convert it into a TTF. The issue is that I can use this TTF font in Libre Office, and view it using the TTF viewer without a problem, however when I ask conky to render it it gives me normal text letters. Why?
    I have no idea why. But I see perfectly what you mean. I previously used another conkyweather that I didn't originally write. It was based on google weather by Hardik Mehta and used a TTF font to display weather symbols. It worked well for a year or two. I used it under Ubuntu, openSUSE (hence my package), Fedora, Mandriva, ArchLinux and Mint. (you can see screenshots in this post Easy configuring conky with conkyconf post #1). Since Ubuntu Oneiric, I began to see normal letters, just like you did ... but interestingly, after a while the letters turned to symblols ... and I wasn't able to understand how it happened. Recompiling conky didn't help. Neither did re-downloading weather info (this script used google api), nor refreshing the font cache or restarting X. All I had to do was to wait a couple hours (without rebooting). Strange isn't it? If you find the answer, I would be interesting to read it - although after all I think that icons look prettier.

    I had this conky set up on half a dozen machines with Ubuntu and it was always the same scenario, with any DE or wm, however only under Ubuntu and Mint. I'm not sure if I started to have the same problem under openSUSE - maybe (?) ... - but meanwhile Google decided to shut down its api and the old script became useless. I decided to rewrite it from scratch, this time using png icons instead of ttf fonts (which requires imlib2 support in conky).

    .

  3. #3

    Default Re: Conky weather font rendering help

    Alright, thanks anyway. Like I said another font I personally compiled looks just fine when conky renders it...it makes no sense at all. If anyone can get this ttf working let me know how.

    On a similar topic do you know how to pull album art from an ID3 tag for conky display? I have seen codes that do this via the internet, but I only want to display art if it is embedded in the tag. (I like to avoid internet pinging when I can and keep it simple.).

  4. #4

    Default Re: Conky weather font rendering help

    Quote Originally Posted by gforce6point0 View Post
    On a similar topic do you know how to pull album art from an ID3 tag for conky display? I have seen codes that do this via the internet, but I only want to display art if it is embedded in the tag. (I like to avoid internet pinging when I can and keep it simple.).
    Try installing libid3tag. See this post: http://forums.opensuse.org/english/o...ml#post2492605

  5. #5

    Default Re: Conky weather font rendering help

    Thanks for the tip. Is there any way to create a temporary variable for images i.e:
    Code:
     ${image ${execpi 5 python WeatherScript.py -Picture} -p 0,0, -s 32x32}
    I attempted this but only got an error (the python script would return an image name. I had to resort to using a static filename, via a copy into a tmp file over for now, but I don't think this is a good practice (especially for my HDD; Correct me if I am wrong...).

  6. #6

    Default Re: Conky weather font rendering help

    Quote Originally Posted by gforce6point0 View Post
    Thanks for the tip. Is there any way to create a temporary variable for images i.e:
    Code:
     ${image ${execpi 5 python WeatherScript.py -Picture} -p 0,0, -s 32x32}
    Use a lua script from conky (and execute your python script from there with the arguments you need).
    Again have a look at my conkyconf and conkyweather, especially in the functions conky_weather and conky_forecast in /etc/conky/conky.lua. These functions execute a bash script, which in turn parses the weather information with xsltproc. This is one out of many ways to do it. You could write similar functions to call a python script.

    Code:
    ${lua_parse  YourLuaFunction arg1 arg2...}
    And YourLuaFunction will pass the arguments to your python script and return strings that you can return to conky.
    I use something like that:

    Code:
    ${lua_parse weather cabc0313 60 /home/openSUSE/agnelo /usr/share/conkyweather/images C}
    ${lua_parse forecast cabc0313 60 /home/openSUSE/agnelo /usr/share/conkyweather/images C}
    where 'weather' and 'forecast' are the functions 'conky_weather' and 'conky_forecast' defined in /etc/conky/conky.lua. This script is loaded (once) in conky by:

    Code:
    lua_load /etc/conky/conky.lua
    And it is much better than using ${execi} or ${execpi} in conky.


    Quote Originally Posted by gforce6point0 View Post
    I attempted this but only got an error (the python script would return an image name. I had to resort to using a static filename, via a copy into a tmp file over for now, but I don't think this is a good practice (especially for my HDD; Correct me if I am wrong...).
    It's poor engineering indeed.

  7. #7

    Default Re: Conky weather font rendering help

    Interesting, why is execpi/execi not preferred, and what else would you use them for other than to call scripts? I just now took a look at lua, and it seems to be a scripting language, just like python...Why is lua preferred when using conky (The python script would work perfectly fine if the ttf font I created would just render properly in conky, does anyone have one that does?). Sorry I'm trying to better understand and explore. The joys on nixing

  8. #8

    Default Re: Conky weather font rendering help

    Quote Originally Posted by gforce6point0 View Post
    Interesting, why is execpi/execi not preferred, and what else would you use them for other than to call scripts?
    These commands use a lot of resources - that you can actually monitor with conky.

    Quote Originally Posted by gforce6point0 View Post
    I just now took a look at lua, and it seems to be a scripting language, just like python...Why is lua preferred when using conky (The python script would work perfectly fine if the ttf font I created would just render properly in conky, does anyone have one that does?).
    I don't know. Ask the conky devs! They implement lua API. They could probably have implemented python API too, but they didn't. Maybe they will some day. I believe that your ttf font would work perfectly fine. Actually I also have the function you need in lua - to display weather icons with a ttf font - because I have been using this method before. You could pretty much use this function with some minor changes or maybe not even. But it wouldn't help. I don't think the font rendering issue has anything to do with conky. As I said I started to have this issue with Ubuntu Oneiric, but I never had it before. As for openSUSE, I'm not sure. Under Ubuntu Oneiric, I was using conky 1.8.1. I decided to compile and use conky 1.9.0.It changed absolutely nothing. I haven't been able to find the cause of this problem. Then I switched to Ubuntu Precise and the problem remained. You could try to install openSUSE 11.4 (or maybe 12.1) and Ubutu Natty or Maverick in virtual machines and test conky with your script and your ttf font. My guess is that it will be OK there.

  9. #9

    Default Re: Conky weather font rendering help

    Haha. Ya, well that is good to know. I was really trying to get the weather script working for my netbook which has CrunchBang installed on it. Currently I have a text based weather system that is stealing xmms from the NOAA website. Here my choppy python script if anyone else wants to use/refine it.

    Code:
    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    ###############################################################################
    #            RETRIEVES NATIONAL WEATHER SERVICE XMMS FEEDS (USA )             #
    ###############################################################################
    
    
    # CREATE A FILE CWI.cfg WITH THE CALL SIGNS OF THE NEAREST 
    # AIRPORT CALL SIGN AND STATE ABBREVIATION EXAMPLE 
    #(EXTRA # INCLUDED FOR COMMENT):
    
    
    ###WEATHER (EL PASO, TX)
    ##CALLSIGN #STATE
    #KELP TX
    
    
    #THEN USE python CWI.py -l: CURRENT LOCATION
    #  OR USE python CWI.py -t: CURRENT WEATHER TYPE
    #  OR USE python CWI.py -T: CURRENT TEMPERATURE
    #  OR USE python CWI.py -P: CURRENT FORCAST PICTURE/SYMBOL
    #FOR EXTENDED FORECASTS USE
    #  OR USE python CWI.py -et <ndays+>: WEATHER TYPE <ndays+> IN ADVANCE
    #  OR USE python CWI.py -eT <ndays+>: TEMPERATURE FORECAST <ndays+> IN ADVANCE
    #  OR USE python CWI.py -eP <ndays+>: PICTURE/SYMBOL <ndays+> IN ADVANCE
    #  OR USE python CWI.py -D <ndays+>:  TO OUTPUT THE DATE OF <ndays+>
    
    
    #NOTE: THERE MAY ONLY BE A 4 DAY OUTLOOK!
    ################################################################################
    
    
    import sys
    import os
    import logging
    import time
    from datetime import datetime, timedelta
    import urllib
    
    
    global upath
    
    
    upath = os.path.expanduser("~/")
    
    
    #READ SAVED LOCATION DATA
    def readSavedSettings():
        
        settings = open(upath+"/CWI.cfg",'r')
        linesread = 0
        while True:
            text = settings.readline()
                #LOOK FOR EOF
            if text == '':
                   #print "EOF"
                break
            if linesread == 1:
                break
                #OTHERWISE READ
            elif text[0] == '#':
                    #print text
                continue
            
            elif linesread == 0:
                call_sign, state = text.split()
                linesread = linesread + 1
                
        settings.close()
        
        return (call_sign, state)
    
    
    #REMOVE XML FORMATTING GARBAGE ----------------------------------------------------------------
    def Remove_XML_Junk(string):
        for i in range(0, 2):
            openbracket = string.find("<")
            closebracket = string.find(">")
            removestr = string[openbracket:closebracket+1]
            string = string.replace(removestr, '')
            string = string.strip()
        return(string)
    
    
    #REMOVE LIST QUOTES ---------------------------------------------------------------------------        
    def Get_Quoted(string):
        openquote = string.find('"')
        closequote = string.rfind('"')
        string = string[openquote+1:closequote]
        return(string)
    
    
    #GET CURRENT FORECAST INFO
    def ParseCurrentNWSXML(CurCond, CurXMLfeed):
            
        while True:
              xmltext = CurXMLfeed.readline()
              #print xmltext
              CurCond.append(Remove_XML_Junk(xmltext))
              if xmltext == '':
                 break
              
        CurCond = CurCond[15:len(CurCond)-10]
        #print CurCond
    
    
        Location = CurCond[0]
        curtemp_str = CurCond[7] 
        return CurCond
    
    
    #GET 48 HOUR WEATHER RESULTS
    def ParseNWSXML(TempMin, TempMax, PrecipC, WeathType, TextFcast, XMLfeed):
        
        while True:
            xmltext =  XMLfeed.readline()
            #print xmltext
            
            minTemps = xmltext.find("Daily Minimum")
            if minTemps != -1:
                for i in range(0, 7):
                    TempMin.append(Remove_XML_Junk(XMLfeed.readline()))
                    
            maxTemps = xmltext.find("Daily Maximum")
            if maxTemps != -1:
                for i in range(0, 7):
                    TempMax.append(Remove_XML_Junk(XMLfeed.readline()))
                    
            precChance = xmltext.find("12 Hourly Probability of Precipitation")
            if precChance != -1:
                for i in range(0, 7):
                    PrecipC.append(Remove_XML_Junk(XMLfeed.readline()))
                    
            wX = xmltext.find("Weather Type, Coverage, Intensity")
            if wX != -1:
                for i in range(0, 7):
                    WeathType.append(Get_Quoted(XMLfeed.readline()))
                    
            wForecast = xmltext.find("Text Forecast")
            if wForecast != -1:
                for i in range(0, 14):
                    TextFcast.append(Remove_XML_Junk(XMLfeed.readline()))
                    
            if xmltext == '':
                break
    
    
            
        return[TempMin, TempMax, PrecipC, WeathType, TextFcast]
    
    
    #GET DATA FROM NWS -------------------------------------------------------------------------------------------------------------
    def getWeather(wtp, days_ahead=0):
    
    
        global path
        days_ahead = int(days_ahead)
        
        #####################################################################
                    
        TempMin = []
        TempMax = []
        PrecipC = []
        WeathType = []
        TextFcast = []
        CurCond = []
        CallList = []
        
        call_sign, state = readSavedSettings()
        date = datetime.today() + timedelta(days=days_ahead)
        date = str(date).split(' ')
        year, month, day = date[0].split('-')
        CurXMLfeed = urllib.urlopen("http://www.weather.gov/xml/current_obs/"+call_sign+".xml")
        CurCond = ParseCurrentNWSXML(CurCond, CurXMLfeed)
        latitude = CurCond[2] 
        longitude = CurCond[3]
        XMLfeed = urllib.urlopen("http://forecast.weather.gov/MapClick.php?lat="+latitude+"&lon="+longitude+"&FcstType=dwml")
        TempMin, TempMax, PrecipC, WeathType, TextFcast = ParseNWSXML(TempMin, TempMax, PrecipC, WeathType, TextFcast, XMLfeed)
        
        #print date
        #print TempMin
        #print TempMax 
        #print PrecipC
        #print WeathType
        #print TextFcast
        #print CurCond
    
    
        #return [TempMin, TempMax, PrecipC, WeathType, TextFcast, CurCond]
        #FOR NOW THE CURRENT CONDITION IS A GOOD START, TRY AND FIX THE REST LATER
        #FORMAT THIS FOR AN EAST CONKY PRINT???
        ccond_type = CurCond[6]
        ccond_temp = CurCond[7]
        ccond_loca = CurCond[0]
        
        if wtp == '-D':
            print month+'-'+day
        #PRINT THE WEATHER TYPE
        if wtp == '-t':
            print ccond_type
        #PRINT THE EXTENDED FORECAST WEATHER TYPE X days_ahead OF CURRENT
        if wtp == '-et':
            if days_ahead -1 >= 0:
                print WeathType[days_ahead-1]
        #PRINT THE CURRENT TEMPERATURE
        if wtp == '-T':
            print ccond_temp
        #PRINT THE EXTENDED FORECAST HIGH & LOW TEMPS
        if wtp == '-eT':
            if days_ahead -1 >= 0:
                print TempMax[days_ahead-1]+'/'+TempMin[days_ahead-1]
        #GIVE THE REPORTING LOCATION OF THE FORECASTS
        if wtp == '-l':
            print ccond_loca
        #GET THE CURRENT WEATHER PICTURE TYPE
        if wtp == '-P':
           if (ccond_type.lower().find('cloudy') != -1 and ccond_type.lower().find('partly')) or (ccond_type.lower().find('overcast') != -1):
               print 'C'
           if (ccond_type.lower().find('rain') != -1):
               print 'R'
           if (ccond_type.lower().find('sunny') != -1) or (ccond_type.lower().find('clear') != -1) or (ccond_type.lower().find('fair') != -1):
               print 'S'
           if (ccond_type.lower().find('snow') != -1) or (ccond_type.lower().find('sleet') != -1):
               print 'O'
           if (ccond_type.lower().find('partly cloudy') != -1) or (ccond_type.lower().find('a few clouds')) != -1:
               print 'P'
           if (ccond_type.lower().find('thunder') != -1) or (ccond_type.lower().find('tstorm') != -1):
               print 'T'
           #if (ccond_type.lower().find('windy') != -1) or (ccond_type.lower().find('gusty') != -1):
               print 'W'
        return ()
    
    
    if __name__ == "__main__":
        if len(sys.argv) == 2:
            getWeather(sys.argv[1])
        else:
            getWeather(sys.argv[1], sys.argv[2])

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •