Tagged: openbox Toggle Comment Threads | Keyboard Shortcuts

  • hardikmehta 7:35 am on August 4, 2009 Permalink | Reply
    Tags: bash, , , , , , kde, , , openbox, 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 9:04 pm on April 14, 2009 Permalink | Reply
    Tags: , , , lxde, mc, midnightcommander, , openbox, tint2, trayer, urxvt, visibility   

    Quest for Window Manager: Openbox 

    Although, I loved using Fluxbox, I started feeling it a bit monotonous and limiting in configuration options. Then I came to know about Openbox. Openbox is also a *box style window manager which is very lightweight and highly configurable. The website also claims it to be more compliant with the freedesktop.org standards. LXDE is actually openbox as window manager with a fixed set of accompanying programs. Openbox can integrate very well with KDE or GNOME, actually in Debian if you install openbox, you will automatically have a choice of booting into “openbox-kde” , “openbox-gnome” or openbox session. I generally prefer the pure openbox.

    The most apparent  difference a fluxbox user will notice while starting  the default configuration of Openbox will be that the good old taskbar generally also containing  a clock and a systemtray is gone. This doesn’t mean that you cannot use any taskbar with openbox, but by default there is none. This gives the user freedom of using any separate taskbar program ( e.g. fbpanel, pypanel, tint2 just to name a few) that suits her.  And in case you are happy with the ALT+TAB menu, you don’t have to use any taskbar or panel. As can be seen in the screenshot, I use tint2 as taskbar. Since we don’t have any systemtray by default, there are some programs like stalonetray, trayer etc which can be used. That of  course if you want to use any.

    Instead of being able to do everything under the sun, openbox does the only one  task i.e. managing the windows and It does it well. In my opinion this is consistent  with the philosophy of Unix commands which perform a very small task and they do it well. Another thing which I like  as a programmer is that the configuration file is xml based. This is of course a negative point for others who don’t find xml “human readable”. In fact I have seen many excellent looking and extremely geeky desktops which are configured by people having very little or no programming experience. So I think it is not at all required to be a programmer  to be able to tailor your desktop to your needs. It is enough just to have basic command-line skills, patience to read the documentation and spare hours in the night for tinkering.

    As a drawback the first thing comes into my mind is that unlike fluxbox, the themes don’t include the panel or the taskbar. In fluxbox if you decide to change the theme the fbpanel is included in the theme configuration and automatically adapts to the new colors and fonts. As the panel is not part of openbox, the theme configuration obviously doesn’t include it so in case you are using a standalone panel, you may have to change its configuration to match the openbox theme.  This I think is not a problem for people who don’t use any panel or intentionally want the granularity of configuration.

    I would not discuss the details of installation, configuration and customization here because  I don’t want to document again what is already well documented.  Openbox wiki on its home page has a very nice documentation.  On ubuntu forums, I found an extensive installation and configuration guide for openbox here, which is more or less the second official guide.

    Here are my two sidux desktops running openbox with conky, adesklets, tint2, visibility, trayer, urxvt etc..

    thumb-obshot1

    Click image to view fullsize

    obthumb

    Click image to view fullsize

    Here are the links to my openbox, tint2 and visibility configuration files.

    Main config file: ~/.config/openbox/rc.xml
    Startup file: ~/.config/openbox/autostart.sh
    Menu file: ~/.config/openbox/menu.xml
    Tint2 config: ~/.config/tint2/tint2rc
    visibility config: ~/.config/visibility/config

     
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: