Tagged: fluxbox Toggle Comment Threads | Keyboard Shortcuts

  • hardikmehta 7:35 am on August 4, 2009 Permalink | Reply
    Tags: bash, , , fluxbox, , , kde, , , , plugin, , weather forecast, , xml, xslt, xsltproc   

    A script to display weather forecast for conky 

    Conky is undoubtedly the most configurable, versatile and amazing program I have ever come across.  With very little effort you can get a very sleek looking desktop. I have seen people using it to display all kinds of information under the sky.  Although, it can only display pure text, there is a possibility to use different symbolic fonts to display text based images.  Moreover, it is also very efficient program. Its own footprint is very small compared to most of the gadget frameworks like adesklets, gDesklets and of course plasma.  Configuration is also relatively easy. The best way is to copy configuration file from some one else and keep on changing it until you get what you want.  Another application worth mentioning here is dzen2. Dzen2 has ability to render any text graphically, although it lacks the built in variables of conky. In archlinux there is an application package called conky-cli which is a stripped down version of conky without X11 dependency. A combination of conky-cli and dzen2 is then used to make taskbars for minimalistic desktops like xmonad, wmii, dwm etc. Personally, I haven’t tried this combination yet.

    conky screen shot

    Ubuntu and Archlinux forums have dedicated threads with conky screen shots and config files. I came across many screen shots with weather information, forecast and small symbols with weather conditions. Most of them were using a perl script (for which I cannot find the link now) to fetch, parse and show the weather information from weather.com.  The weather symbols were ttf fonts.  I didn’t want to take the script one-to-one and perl is anyway too cryptic for me to  decipher. I decided to take the concept and develop something similar on my own.

    So I created the google weather script. It is a simple bash script to fetch the xml file using google weather api, I changed the source because although weather.com was providing good information, they were changing the format of the request too often, their terms and conditions of usage were also not very comprehensible for me. Then I use different style-sheets to process the xml response and show different information depending on the argument passed to the bash script. I also use the weather.ttf fonts to render the symbols for different weather conditions.  For transforming xml, I use the xsltproc tool.

    Here is the conky running under kde4 desktop. With different desktop environments       conky needs to be adjusted  a bit. Another weakness of conky in integrating external scripts is that the output must be pre-formatted before supplying it to conky. Conky just takes the text and renders it.  In principle any executable can be called from conky to display its output.

    Conky has many built-in variables for displaying common system parameters which are well documented on the official documentation page. Besides the common parameters like cpu / memory usage, uptime, upload-download speed, top 3 cpu using processes and top 3 memory using processes, the screen shot on the left also displays the dictionry.com word of the day rss feed, which I find extremely useful. It also uses a similar script and xslt transformation. There is also a built-in rss feed processor in conky.

    I use mpd for playing music. There is also built-in mpd support in conky and can be used to display information about current song being played. If you want to show different information at different places on the desktop, it is also possible to have multiple instances of conky running at the same time with different configuration files.

    As evident  in the screen shot it is difficult to adjust the spacing of the weather output due to mixing of different types and sizes of  fonts.  My script only considers some frequent weather conditions, but it can easily adapted to support many different weather conditions.  The spacing must be adjusted for individual setup by editing the line no. 16 in the  file fcConditions.xslt

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
        <xsl:include href="conditionsInclude.xslt"/>
        <xsl:output method="text" disable-output-escaping="yes" encoding="utf-8"/>
        <xsl:template match="xml_api_reply">
            <xsl:apply-templates select="weather"/>
        </xsl:template>
    
        <xsl:template match="weather">
            <xsl:for-each select="forecast_conditions&#91;position() >= 2]">
               <xsl:call-template name="get-condition-symbol">
                    <xsl:with-param name="condition">
                        <xsl:value-of select="condition/@data"/>
                    </xsl:with-param>
                </xsl:call-template>
                <xsl:if test="position() != 3">
                    <xsl:text> </xsl:text>
                </xsl:if>
            </xsl:for-each>
        </xsl:template>
    </xsl:stylesheet>
    

    I have hard-coded the update interval to 1 hour. This can also be changed very easily to the required value by changing the value of the update variable in the weather.sh file.

    # don't get the file if created within an hour
    update=3600
    

    I use mainly following configurations for conky.

    I have released the script with GPL V3 license, so feel free to use it if you like it. Please comment about any bug reports, improvements, questions or suggestions.

    Advertisements
     
    • antibalas 4:40 am on October 30, 2009 Permalink | Reply

      great work.

    • foenOsteotNox 12:17 am on December 11, 2009 Permalink | Reply

      I’m often searching for recent blogposts in the WWW about this issue. Thx!

    • webrev 7:13 pm on August 6, 2010 Permalink | Reply

      Love the google weather script. Thanks. Can someone tell me how to change the temp units to standard. I have changed in weather.sh

      1. s=standard units, m=metric units

      UNITS=s

      But it still reports as metric.

      • hardikmehta 8:16 pm on August 6, 2010 Permalink | Reply

        Hi,

        Thanks for using the script. The UNITS variable is obsolete with the google api implementation. It worked with the weather.com version.

        With google apis, it is a bit different. The default locale of the url is “us” which is used in the script. In this case the temperatures are provided in both metric and standard units. See temp_c elements in the xml http://www.google.com/ig/api?weather=Munich,Germany

        If you want a localized output please append hl=[iso locale code] to the url, but then the output is also in the language specifed by the locale, so the script is not guranteed wo to work with it.

        example of German locale (de)
        http://www.google.com/ig/api?weather=Munich,Germany&hl=de

        I hope this helps. Feel free to ask if you have further questions.

    • Ben Brown 5:54 pm on February 23, 2011 Permalink | Reply

      Just wanted to let know how much I appreciate the work you did on the weather program for conky. I don’t understand all the programs and coding, but I am working my way through the code and have been able to get it to work for me here in Michigan, USA.

      Again, thank you so much for sharing this with the community.

      • hardikmehta 6:01 pm on February 23, 2011 Permalink | Reply

        Hi, Thanks. Glad that it worked for you.

    • Agnelo de la Crotche 2:26 pm on May 21, 2011 Permalink | Reply

      Great job! What about packaging it for different distros in OBS (https://build.opensuse.org) ?

  • hardikmehta 6:04 pm on February 15, 2009 Permalink | Reply
    Tags: , , fluxbox, , ,   

    Quest for Window Manager: Fluxbox 

    I am sure much has been written  about different window managers under GNU/Linux operating system. Here I present my journey and experience with them. This is how it started.

    I was a Windows user. I started to hear about Linux and got inspired to try knoppix live cd. It was really a nice experience and I started admiring how Linux stays out of your way when you want to work with your system. Then I decided  to install a suitable distribution on my hard disk, but the problem was that I had only 4.5 GB hard disk at that time, so I started searching for  a light distribution which could fit. The choice then fell on feather linux. It is really a very  light (under 128mb) but nice knoppix based distribution, so after installation it is essentially debian with some knoppix quirks. The only problem I faced with feather linux at that time was that it came with  fluxbox as the default window manager.

    To be honest, at first, fluxbox looked  frightening due to my  KDE background, no launch button, only right-click menu and even for a simple task like getting the same wallpaper every time you boot, you have to edit a configuration file. But after leaning to work with it, I started admiring fluxbox. I also found it easy to configure by editing simple text based config files. With time, I got so fond of fluxbox that even when I had ample disk space to install KDE, I opted for fluxbox when I installed my first real debian based (as feather linux was based on knoppix) distribution, sidux. As the name suggests sidux is based on debian sid and one of the most cutting edge and fastest distros, more on sidux some other time. Here is how my desktop looks running sidux and fluxbox tweaked to my taste and with some other gadgets I like.

    thumb-fluxbox

    Fluxbox is highly configurable and very well documented. The wiki here a good place to start to learn how to configure fluxbox.

    My fluxbox configuration files can be found here:

    I can also provide the supporting scripts which I have written and may be referenced by the above files.

    Now, the only short coming of fluxbox in my opinion is that there is a limit how much you can configure it. After some time I had a feeling that my desktop was becoming monotonous. Also considering the resource consumption, fluxbox is not the slimmest among the  light window managers.

    Moreover, I had started following the monthly screenshot threads on the highly geeky  archlinux and ubuntu forums. There the posts are like “pimp my desktop” shows, the screenshots are so tempting that you are compelled to ask them how they achieved that look or what program was that little clock in the corner. So, I also had a wish to “pimp my desktop” and try something new.

     
    • ruchir 4:53 am on March 30, 2009 Permalink | Reply

      Good information about linux operating system and various options.

c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: