Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • hardikmehta 3:58 pm on December 13, 2011 Permalink | Reply
    Tags: awesome, desktop enviroment, dwm, haskell, musca, ratpoison, tiling wms, tmux, window managers, wmii, xmonad   

    Quest for Window Manager: Xmonad 

    While I was tweaking a lot with my fluxbox and openbox desktop, I came to know about the tiling window managers like wmii, dwm, xmonad, awesome, musca, ratpoison etc. These wms[1] are very lightweight, minimalist and completely different in paradigm than the non-tiling wms. The main difference being that they manage the placing and if necessary sizing of the windows themselves and as a user you are relieved from these mundane tasks. At first, with the word “tiling” I just recalled the option in Windows 3.1 which was used to arrange the windows as tiles on the desktop. At that time though, it made less sense as the screen sizes were generally very small. But now a days, with wide screens and often multiple monitors attached,  tiling your windows makes  good use of your real estate on the screen. At first, it feels a bit different, but after some usage, I realised that it can be very useful if you don’t have to spend time arranging windows on your desktop. You utilise maximum of your desktop space and save a lot of time so you can hack without any bells and whistles of a Desktop Environment coming in your way.

    All the window managers mentioned above have their own peculiarities and features. I don’t want to go into the details of each one so,  here is the archlinux wiki page which compares the different tiling window managers.

    My choice fell on xmonad. It has several reasons. The first being it looks awesome (no pun intended). The second being the language behind it, yes haskell[2].  The configuration file is also written in haskell, with which it is possible to customize and  extend the basic features provided by xmonad.  It  surely is a challenge to learn a fresh new language to be able to understand the configuration file and  to customize. This actually was a plus point for me because  I already had heard  many interesting things about haskell, so  I wanted to learn it to have a feel of  a lazy and purely functional language.  So, xmonad being a new paradigm window manager for me, it was also an opportunity for me to start learning haskell.

    Some screenshots to give you  a feel of what I am talking about.

    Xmonad Clean

    Xmonad clean with conky, dzen , conky, mpd, weather status bar

    Xmonad Busy

    Xmonad running tmux and vim editing the primary configuration file of xmonad.

    Xmonad is a very efficient dynamic tiling window manager which is very slim in terms of memory usage. Although the core part is relatively plain in terms of features, there are plenty of extensions which could be used to take advantage of different features.  Although for me it was an interesting  opportunity to start learning  haskell and understand the config file,  it is not at all necessary to learn haskell to configure xmonad. There are many example configurations available on the xmonad site with screenshots.  The xmonad config file is generally well  readable, so it is possible and often recommended  to initially copy an example configuration and keep on modifying it until you get it customized to your needs. I also liked the way xmonad handles multiple screens. Actually in the beginning it felt a bit  strange, but after some experience with it,  it is so  intuitive, that you would not like multiple screen handling of any other window manager.

    This  is  my config file which is more or less a basic configuration with some changes.  Please feel free to suggest any improvements or changes. I have started learning haskell by following the book Real World Haskell, which in my opinion is a very good book for beginners. Please feel free to suggest any other useful resources for that as well.  I hope I will be able to use more of xmonad and fix some issues I am having with it.

    On the cons side, xmonad doesn’t handle swing (java) based applications very well. There is a workaround in the config file by setting the param  setWMName  to “LG3D” to get it working.  I am still  having problems related to focusing with eclipse java IDE.  I am looking for a solution to this issue.

    Links:

    1. Window Managers

    2. Haskell

     
    • Toni Cebrián 11:00 am on December 18, 2011 Permalink | Reply

      Check my blog for a fully working solution of the Java/Swing problem you mention. I was having big problems with Xmonad and IntelliJ and this configuration solved all them. http://www.tonicebrian.com/2011/09/05/my-working-environment-with-xmonad/

      • hardikmehta 2:26 pm on December 18, 2011 Permalink | Reply

        Thanks for your response. I will surely check your blog, and let you know if it works for me too.

    • none 9:53 pm on December 19, 2011 Permalink | Reply

      You might also like the book Learn You A Haskell (also online like RWH):

      http://learnyouahaskell.com

    • lazzari storage 11:02 am on May 8, 2013 Permalink | Reply

      Hello, I think your site might be having browser compatibility issues.

      When I look at your blog in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping.
      I just wanted to give you a quick heads up! Other then that,
      fantastic blog!

    • 商標註冊 2:58 am on July 12, 2014 Permalink | Reply

      Useful information shared..Iam very happy to read this article..thanks for giving us nice info.Fantastic walk-through. I appreciate this post.

  • hardikmehta 12:15 pm on April 30, 2010 Permalink | Reply
    Tags: , , , , ,   

    Mavenising seam projects [ part 2 ]. 

    This part will continue the discussion started in part 1 [1].

    We now come to the model and action modules which are of type ejb. Particularly in this example (Open18) they are just seam components i.e. pojos  annotated with @Name, but they could also have been ejbs.

    Bellow is the pom.xml for model module. It contains all the entities (JPA)  and some helper classes. It shows jboss-seam as provided dependency which will be provided by the ear module which packages the artifact which will be deployed. This modules takes all the hibernate dependencies from the parent project.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <parent>
        <groupId>com.hardik.seaminaction</groupId>
        <artifactId>Open18</artifactId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.seaminaction</groupId>
      <artifactId>model</artifactId>
      <packaging>ejb</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>model</name>
      <url>http://maven.apache.org</url>
      <dependencies>
          <dependency>
                <groupId>org.jboss.seam</groupId>
                <artifactId>jboss-seam</artifactId>
                <version>2.2.0.GA</version>
                <type>ejb</type>
                <scope>provided</scope>
            </dependency>
      </dependencies>
      <build>
      	<plugins>
      		<plugin>
      			<groupId>org.apache.maven.plugins</groupId>
      			<artifactId>maven-ejb-plugin</artifactId>
      			<configuration>
      				<ejbVersion>3.0</ejbVersion>
      			</configuration>
      		</plugin>
      	</plugins>
      </build>
    </project>
    

    Here the action module which is also of type ejb. It contains all the action classes which are in turn pojos annotated with @Name. The JSF dependency which we see is for the JSF message classes.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <parent>
        <groupId>com.hardik.seaminaction</groupId>
        <artifactId>Open18</artifactId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.seaminaction</groupId>
      <artifactId>action</artifactId>
      <packaging>ejb</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>action</name>
      <url>http://maven.apache.org</url>
      <dependencies>
          <dependency>
              <groupId>com.hardik.seaminaction</groupId>
              <artifactId>model</artifactId>
              <version>1.0-SNAPSHOT</version>
          </dependency>
    
          <dependency>
                <groupId>org.jboss.seam</groupId>
                <artifactId>jboss-seam</artifactId>
                <version>2.2.0.GA</version>
                <type>ejb</type>
                <scope>provided</scope>
            </dependency>
          <dependency>
                <groupId>javax.faces</groupId>
                <artifactId>jsf-api</artifactId>
                <version>1.2_02</version>
                <scope>provided</scope>
            </dependency>
    
      </dependencies>
      <build>
      	<plugins>
      		<plugin>
      			<groupId>org.apache.maven.plugins</groupId>
      			<artifactId>maven-ejb-plugin</artifactId>
      			<configuration>
      				<ejbVersion>3.0</ejbVersion>
      			</configuration>
      		</plugin>
      	</plugins>
      </build>
    </project>
    

    Links:

    1. Mavenising seam projects [ part 1 ].
     
  • hardikmehta 3:51 pm on March 7, 2010 Permalink | Reply
    Tags: cdi, , , , jsr 299, jsr299, , , ,   

    Mavenising seam projects [ part 1 ]. 

    Seam [1] is a  very powerful framework for developing java EE web-based applications. It is the only java framework which glues all the tiers of a typical java EE web application together. It is no surprise that many seam features like using EJB 3.0  (for seam any pojo which is a seam component) directly as JSF backing beans, declarative scoping and conversation scope  has been included in the new Contexts and Dependency Injection for Java EE 6 (CDI) also known as JSR 299 [2].  JSR 299 combines best features of seam, Google Guice [3] and Spring [4]. Seam also has tons of other features which make it a very useful framework to learn for any Java developer. Seam by default uses ant. The seam-gen tool creates an ant project and itself is a wrapper to different ant targets.

    Maven on the other hand is emerging as the de-facto building tool for java. As I have already mentioned before, maven gives you a very good overview of your project and you are not lost in minor details. Those details are automatically taken care of. With seam projects, maven is especially useful because you know which dependencies are needed.

    When I started learning seam, by reading the very popular book Seam in Action by Dan Allan [5], I had already switched to maven for all my projects. I decided to mavenise the examples of the book. There are many such projects. The seam documentation also points to the seam-maven-refimpl project [6] which provides a nice template for any seam project. As I wanted to find out how the maven implementation a seam project differs from that of a standard java EE project first hand, I didn’t use the template provided by this project. I just started with a standard java EE project and started adding seam dependencies to it, until I had a working example.

    The implementation  can be found here. Please feel free to point out any mistakes or suggest improvements to th code.

    I have also tried to convert the first examples of the book Seam 2.x Web Development by David Salter [7]. These examples are very simple i.e. without persistence, richfaces etc, although they use state less session beans.

    Here I will discuss the Open18 example from the Seam In Action book in detail.

    Here is the pom file of the main parent project which is no different from an ordinary Java EE project. The only seam specific thing is the jboss repository entry at the end.

    <?xml version="1.0" encoding="UTF-8"?>
    xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.seaminaction</groupId>
      <artifactId>Open18</artifactId>
      <packaging>pom</packaging>
      <version>1.0-SNAPSHOT</version>
      <name>Open18</name>
      <url>http://maven.apache.org</url>
      <modules>
      	<module>action</module>
      	<module>model</module>
        <module>war</module>
        <module>ear</module>
      </modules>
      <build>
      	<plugins>
      		<plugin>
      			<groupId>org.apache.maven.plugins</groupId>
      			<artifactId>maven-compiler-plugin</artifactId>
      			<configuration>
      				<source>1.6</source>
      				<target>1.6</target>
      			</configuration>
      		</plugin>
      	</plugins>
      </build>
      <dependencyManagement>
      	<dependencies>
      		<dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>ear</artifactId>
      			<version>1.0-SNAPSHOT</version>
      		</dependency>
      		<dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>war</artifactId>
      			<version>1.0-SNAPSHOT</version>
      		</dependency>
      		<dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>action</artifactId>
      			<version>1.0-SNAPSHOT</version>
      		</dependency>
            <dependency>
      			<groupId>com.hardik.seaminaction</groupId>
      			<artifactId>model</artifactId>
      			<version>1.0-SNAPSHOT</version>
            </dependency>
      	</dependencies>
      </dependencyManagement>
        <dependencies>
            <!-- hibernate dependencies with provided scope -->
        </dependencies>
    
       <repositories>
      	<repository>
      		<id>jboss</id>
      		JBoss Repository
            <url>http://repository.jboss.org/maven2/</url>
      	</repository>
      </repositories>
    </project>
    

    Links:

    1. Seam
    2. Contexts and Dependency Injection in Java EE 6 (JSR 299)
    3. Google Guice
    4. Spring framework
    5. Seam in action
    6. Seam maven reference implementation
    7. Seam 2.x Web Development

     
  • hardikmehta 2:24 pm on March 7, 2010 Permalink | Reply
    Tags: , , , ,   

    Switched to Archlinux 

    At last a new post after a long time !

    Lately, I was very busy with real life issues and concerns so could not find time to write.

    In spite of being a fan of debian [1], I decided to change my operating system. I was completely happy  with sidux [2] which is essentially debian sid with a pinch of spice, but wanted to try something new and different. I had heard a lot of good things about Archlinux [3]. First I decided to try it on a virtual machine and was impressed by the simplicity of the system. It is highly configurable and yet simple when it comes to configuring it to your taste.  For me the common thing is that sidux and Archlinux both are rolling distributions.  Arch claims to be optimized for i686, so at least theoretically it should be faster than sidux. Though,  I don’t have any benchmarks to support this. Debian has may be the highest number of binary packages available, but Arch has AUR [4] and ABS [5], so it becomes easy to compile a package from sources.

    Another reason, I switched to Arch was that I was experimenting with lightweight window managers like fluxbox, openbox, dwm, xmonad etc. The community at Archlinux provides a great support and knowledge base for them. In fact I got encouraged to try those window managers by browsing through the screenshot threads in the Archlinux forums. On the other hand, sidux officially  supports only Kde, and I somehow felt that the community at sidux discourages the use of alternatives to kde and also other lightweight applications.

    Although, it was not GUI based like sidux, the installation of Arch went rather smoothly. Archwiki [6] is an indispensable resource. I have a 4 years old Dell Inspiron 6000. The system seems to run smoothly. There are less daemons running compared to sidux, so the boot time is less. I have more or less the same setup as my sidux installation with openbox as main window manager and kde 4 as a fallback ! I am also maintaining my plasmoid plasma_pyweather [7], so I don’t want to get rid of kde altogether.

    I don’t know yet, if I will continue with Arch or go back to sidux again. I have realized that you need to read all the messages carefully when you upgrade the system with pacman, this was also true for sidux, but the forum with upgrade warning was a great help.  Anyway, I hope to post interesting things about my experience using Arch.

    Here some screenshots for those who want to see it to believe.

    Arch clean

    Arch dirty

    Links:

    1. Debian GNU/Linux
    2. sidux
    3. Arch Linux
    4. Arch User Repository
    5. Arch Build System
    6. Arch Wiki
    7. A weather plasmoid in python

     
    • Med Berdai 7:32 pm on March 8, 2010 Permalink | Reply

      Hi fellow Archer :)

      I’ve been using it exclusively for almost 2 years now, it never failed me and I didn’t miss Debian at all. Arch Linux is absolutely one of best GNU/Linux distros out there.

      Now that I grown feed up of Arch Linux being so reliable I started messing with FreeBSD and LinuxFromScratch :)

      Happy hacking,

      Med,

  • hardikmehta 8:52 am on September 12, 2009 Permalink | Reply
    Tags: , java-server-faces, , jsf, ,   

    Maven dependencies for a basic JSF project 

    With some search and experiments, I figured out the following maven dependencies for a basic JSF project. These dependencies also allow autocompletion of JSF tags in the IDEs like eclipse and intellij idea. I post this for my own reference and may be someone searching for it.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.hardik.jsfinaction</groupId>
      <artifactId>HelloJsf</artifactId>
    <packaging>war</packaging>
      <version>1.0</version>
      <name>HelloJsf Maven Webapp</name>
      <url>http://maven.apache.org</url>
      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.0</version>
          <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>1.2_02</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>1.2-b19</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
      </dependencies>
      <build>
        <finalName>HelloJsf</finalName>
    <plugins>
    <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
    <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <server>tomcat</server>
                </configuration>
            </plugin>
        </plugins>
      </build>
    </project>
    
     
  • hardikmehta 9:02 pm on August 13, 2009 Permalink | Reply
    Tags: , , forecast, , , , plasmoid, pydev, pykde4, pyqt4, Python, python-plasmoid, qt4, ,   

    A weather plasmoid in python 

    Ever since I heard about plasma I was eager to find ways to write my own plasmoid. But for the development of binary plasmoids, it is necessary to compile at least a part of kde4, at least this is what I understood from the prerequisite listed on the official tutorial. This discouraged me a bit. Moreover, I think that installation of the binary gadgets also requires to either package them properly according to the distribution you want to distribute for or you need to provide the sources that requires the users to build them. This  in my opinion is really a huge overhead for small applications like desktop gadgets / widgets. Then I found that it is also possible to develop plasmoids with script languages like python, ruby and javascript.

    Even though, I didn’t know PyQT4 or PyKDE4 libraries at all, I decided to write my first plasmoid in python.  This is an exremely simple plasmoid, the core of which was put together in a few hours on a rainy weekend. I have to admit that being a java developer, my code is not pythonic enough.

    It can be downloaded from: kde-look.

    Here the source code: plasma_pyweather.

    wplasmoid_greytransThe layout is based on my conky setup described here. I have tried to keep it as compact as possible including most of the provided information, if not all.  I don’t want the weather information to cover most of the screen.  The initial version of the plasmoid was written using the QT4 widgets, but was looking ugly.

    The weather information is fetched from google weather api. The location and the unit are configurable. The api provides forecast only for the next 3 days, so the number of forecast days were not made configurable.  Some how for google weather api the locale and so the unit is connected to the language, therefor  I had to convert the units myself. To keep the display compact I rounded the temperatures to integers.

    I got to learn PyQT4 and PyKDE4 libraries while writing this. Especially PyQT4 is a very powerful gui library for python.  It is fun programming with it. I have used eclipse + pydev for developing. In the beginning I didn’t have the auto-completion for PyQT4 as well as PyKDE4 in this environment, because they are not installed as pure python source code files. I could fix this with following answer.

    The other interesting things, I learned was to use the qt-designer tool for creating gui. It is a nice WYSIWYG tool for designing complex guis. The configuration form is designed using this tool. The qt-designer creates a .ui file, which is an xml file. The .ui file can be converted to the python source code using the pyuic4 tool in the following way.

    pyuic4 -o configForm_ui.py ../ui/configForm.ui
    

    I also learned to use the .qrc file for resources like images. The .qrc file can be converted into python source code using  pyrcc4 tool

    pyrcc4 -o images_rc.py images.qrc
    

    The qrc file is also an xml file which contains the references to the images used. It can be created by just editing.

    <RCC>
        <qresource prefix="/images">
            <file alias="sunny.svgz">../images/sunny.svgz</file>
            <file alias="showers.svgz">../images/showers.svgz</file>
            <file alias="not-available.svgz">../images/not-available.svgz</file>
            <file alias="cloudy.svgz">../images/cloudy.svgz</file>
            <file alias="thunderstorms.svgz">../images/thunderstorms.svgz</file>
            <file alias="haze.svgz">../images/haze.svgz</file>
            <file alias="windy.svgz">../images/windy.svgz</file>
        </qresource>
    </RCC>
    

    I decided to write this weather plasmoid in python, because all the other weather plasmoids I found were binaries. I have also tried to keep the data and presentation layer separate, I hope I succeeded in that.  In fact plasma framework provides a very good way of doing that in terms of data engines. I would also like to use the data engines, may be with this or other plasmoid I may develop.

    The svg images for weather conditions are taken from kde-look. The credit goes to the original artist, painkiller10. I have considered only a number of weather conditions, so If you see a question mark image as the weather condition, let me know which condition it is, so I can update the code to consider it.

    Please feel free to report any bugs or suggestions for improvement. I am sure there is a big room of improvement from code point of view as well as functionality. I am also open for changing the layout or changing the information displayed if someone comes with a better suggestion than the current one.

    Some more screen shots:

    Looks almost like conky with the seamless theme.

    Looks almost like conky with the seamless theme.

    wplasmoid_settings

    With settings dialog box

     
    • Paolo 3:18 pm on September 2, 2009 Permalink | Reply

      Beautiful! BTW, could you internationalize your plasmoid? (in order to translate messages in other languages) Thanks.

      • hardikmehta 9:45 am on September 3, 2009 Permalink | Reply

        Thanks.

        I have plans to internationalize it, as soon as I get enough time to work on it.

    • arun kamath 5:04 am on September 13, 2009 Permalink | Reply

      I checked your source code at github. Instructions are for linux users. Can you please tell me how to run your program in windows?

    • Raffaele 2:06 pm on January 13, 2010 Permalink | Reply

      I like your plasmoid a lot, I’m enjoying it for months ;)
      Recently (maybe) google API changed a bit, because I got an error on wind string that halted my plasmoid :( Here is the patch

      http://pastebin.ca/1749545

      Where did you learn graphic widget programming for PyQt? I’d also like to, but I find the official doc inadequate (compared to Java’s for example… I’m a JStudent, too :) )

      Cheers

      • hardikmehta 10:18 pm on January 13, 2010 Permalink | Reply

        Raffaele, thanks a lot. I have committed the patch to the repo and updated the package on kde-look. The incorrect format appears only for certain cities like Hong Kong. I tried to learn PyQT from the official documentation and also studying code of some existing plasmoids. It is true that compared to java, there is little help for learning PyQt or Python in general. I am a java developer just found python interesting. I am not sure about how pythonic my code is though :)

        Cheers.

    • DeltaKilo 4:10 pm on January 17, 2010 Permalink | Reply

      Good work! It is the first plasmoid showing weather in Russia!

      One little issue. SI unit for temperature isn’t °C but °K (Kelvin). It would be better to use imperial/metric switch.

    • DeltaKilo 4:11 pm on January 17, 2010 Permalink | Reply

      & kmph of course.. In SI should be mps

      • hardikmehta 12:05 pm on January 18, 2010 Permalink | Reply

        Thanks for using the plasmoid. Also thanks for pointing out the mistake. I corrected the names of the units and uploaded a new version with the new names. If you upgrade don’t for get to select the new units from the settings dialog box.

    • Raffaele 6:01 pm on April 8, 2010 Permalink | Reply

      Hi, I’m continuing enjoying your plasmoid :D
      I found another little bug (actually a typo error) which sometimes prevents pyweather initialization. The problem occurs in weather.py http://pastebin.com/vX6HtkGb
      I don’t know if it’s fixed in most recent version, neither why sometimes it doesn’t fail. Happy coding!

      • hardikmehta 2:30 pm on April 20, 2010 Permalink | Reply

        Thanks for pointing out. I corrected and committed in the repo. Do you think we need a release for this ? I would rather wait and try to pack some feature with the bug fix.

    • Rick 5:16 pm on April 21, 2010 Permalink | Reply

      Hi, Thanks for the great plasmoid.
      Has everything my wife and I want except the ability to change font color. We noticed that the initial install will put in a dark or light font color (contrasting) according to the wallpaper used at that time. Would like to change the contrast when a different wallpaper is used. Is that possible?
      Thanks again.

      • hardikmehta 7:47 pm on April 21, 2010 Permalink | Reply

        Hi,

        Thanks for using the plasmoid.

        Actually, I just set the default font color for text which is selected by the current KDE theme. So, changing the font color with the current version of the plasmoid is only possible if you change the kde theme, which of course will change many other things. I liked your suggestion and would try to implement the font-color as config properties.

        cheers,
        Hardik

    • AmFreak 3:29 am on June 2, 2010 Permalink | Reply

      Hi,

      im planning to write a Plasmoid myself but i have a question.
      Is there a way to start the Plasmoid from Eclipse or do u have to run a script everytime u want to test it, like seen in the Getting Started Tutorial (http://techbase.kde.org/Development/Tutorials/Plasma/Python/GettingStarted) ?
      Thanks in advance.

      AmFreak

      • hardikmehta 6:43 am on June 2, 2010 Permalink | Reply

        I think pydev plugin provides ways to start any python script from eclipse, but I didn’t use that feature so cannot say how to do it. The recommended way to test is with plasmoidviewer, the application which comes as part of plasma environment.

    • AmFreak 2:34 am on June 5, 2010 Permalink | Reply

      But how can you debug a plasmoid if you only can test it with plasmoidviewer ?

    • luis 6:11 am on November 24, 2010 Permalink | Reply

      Thanks yu very much for the plasmoid, I found it really useful and very stylish.

      One question? is there a way to change the default Munich location? every time that I have to restart or crash, it automatically changes to the default

    • Giorgos Komninos (@giokom) 5:50 pm on March 18, 2012 Permalink | Reply

      I found a bug and it’s solution
      check my comment :

      http://opendesktop.org/content/show.php?content=110137&forumpage=3

      • hardikmehta 10:38 am on March 19, 2012 Permalink | Reply

        Hi Giorgos,

        Thanks for finding and fixing the issue. I will correct and release a new version as soon as I get some time.

        regards,
        Hardik

    • mike welder 1:12 am on September 3, 2012 Permalink | Reply

      as of recently I have not been able to start this “script initialization failed” is the message I get.it was working fine then I had a few updates and the above message started.It’s hard for me to tell which update did it as my computer stays on for weeks at a time with out logout or restart unless I have to so it’s hard for me to tell which update did it and when but it did start after a restart.I’m using fedora 17 kde.dam shame the one reason I’ve been with kde since fedora 15 is the great weather widget and a few others.Great work by the way.It’s not only your work there are a few others with the same message.

  • hardikmehta 7:35 am on August 4, 2009 Permalink | Reply
    Tags: bash, , , , , , 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[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.

     
    • 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 8:56 pm on July 30, 2009 Permalink | Reply
    Tags: config, dotfiles, file sharing, github, repository   

    Created a repository with github for storing / sharing config files 

    I noticed that since long time dotfiles.org website which I used to store and share my config files was unreachable.  So I created a repository with github. It is called dotfiles. I will update all the links pointing to my configs files to the new location. If you still notice some old links please drop a comment.

     
  • hardikmehta 8:03 pm on July 9, 2009 Permalink | Reply
    Tags: ant, apache-maven, build-tools, ejb, ejb3, , , , ,   

    Maven quirk ( archetype-j2ee-simple ) 

    Update:

    The issue has been fixed. There were two points.

    1. I was using the wrong (deprecated) goal archetype:create instead of archetype:generate.

    2. With the plugin archetype-j2ee-simple there is a bug which is already reported here.

    I got my answer from Antony Stubbs on Stackoverflow.

    At last I also decided to join the maven[1] bandwagon, I will start using maven for managing my projects. Convention over configuration  sounds  indeed a nice idea.  When I first heard about maven  I didn’t have a good “feeling” about it, may be because I was too comfortable with ant and believe to be able to achieve any task with it. But now after reading some documentation and articles about maven, I came to realise it is completely new paradigm than ant. In my opinion the best aspect of maven is that you always have the big picture of your project in mind instead of a small task or operation to be done.  I started liking maven and  also started learning it.  For reference I have started following  Maven: The Definitive Guide[2]. Another great advantage could be that if you know maven and a join a new team which also uses maven for project management, you don’t have to spend hours or may be days trying to figure out the structure of their project and being able to build it.

    Although I started liking maven, sometimes it feels like a strange tool, where you have to configure a lot to achieve your goal. if you want some custom stuff in your project. I also find it annoying that by default the compiler-plugin assumes you want to build for java 1.4 or java 1.3.  Moreover, because there are always so called sensible or obvious defaults assumed, in maven world, not all the obvious defaults are obvious to you and you have to know the documentation well to be able to know what those defaults are. and how you can achieve something different. It feels somewhat like javadocs, until you get used to the apis you need frequently, you have to rely on auto-completion of your IDE or have the javadoc always open. There is no wonder that the second part of the book, I mentioned contains only the maven reference.

    But, yes, I am here to talk about the quirk of maven which I encountered during my learning process. I am just a maven beginner, so may be this is normal behavior, but I don’t think so.

    So, while starting to learn maven, I started with a contrived JavaEE application (brave huh), which is taken as example in the very good book EJB 3 in Action[3]. I searched the net and found out about the maven archetype j2ee-simple here. I used following commandline to generate the stubs of a simple JavaEE project, actually I was interested in the standard directory structure.

    mvn archetype:create -DgroupId=com.hardik -DartifactId=ActionBazaar -DarchetypeArtifactId=maven-archetype-j2ee-simple

    The project was created perfectly, but by default it was not compiling. When I executed mvn intall I had following errors.

    $ mvn install
    [INFO] Scanning for projects...
    [INFO] ------------------------------------------------------------------------
    [ERROR] FATAL ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Error building POM (may not be this project's POM).
    
    Project ID: unknown
    
    Reason: Could not find the model file '/home/hardik/projects/ActionBazaar/site'. for project unknown
    
    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    org.apache.maven.reactor.MavenExecutionException: Could not find the model file '/home/hardik/projects/ActionBazaar/site'. for project unknown
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:432)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:300)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.apache.maven.project.ProjectBuildingException: Could not find the model file '/home/hardik/projects/ActionBazaar/site'. for project unknown
        at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1575)
        at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
        at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
        at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:632)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:515)
        at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:588)
        at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:419)
        ... 12 more
    Caused by: java.io.FileNotFoundException: /home/hardik/projects/ActionBazaar/site (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at hidden.org.codehaus.plexus.util.xml.XmlReader.<init>(XmlReader.java:124)
        at hidden.org.codehaus.plexus.util.xml.XmlStreamReader.<init>(XmlStreamReader.java:67)
        at hidden.org.codehaus.plexus.util.ReaderFactory.newXmlReader(ReaderFactory.java:118)
        at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1570)
        ... 18 more
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: < 1 second
    [INFO] Finished at: Thu Jul 09 18:44:31 CEST 2009
    [INFO] Final Memory: 1M/4M
    
    [INFO] ------------------------------------------------------------------------

    It is talking about some model file for the site module. The site module is generally the “website” of your project that maven generates just by looking at your pom.xml file. I removed the site module from the module list of the pom file and it started working. But I still wonder why the default project structure doesn’t build. I am sure this is incorrect behavior.

    If someone has had the same problem, and was able to fix, please let me know.

    References:

    1. Apache-maven
    2. Maven: The Definitive Guide
    3. EJB 3 in Action

    $ mvn install
    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [ERROR] FATAL ERROR
    [INFO] ————————————————————————
    [INFO] Error building POM (may not be this project’s POM).Project ID: unknown

    Reason: Could not find the model file ‘/home/hardik/projects/ActionBazaar/site’. for project unknown

    [INFO] ————————————————————————
    [INFO] Trace
    org.apache.maven.reactor.MavenExecutionException: Could not find the model file ‘/home/hardik/projects/ActionBazaar/site’. for project unknown
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:432)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:300)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.apache.maven.project.ProjectBuildingException: Could not find the model file ‘/home/hardik/projects/ActionBazaar/site’. for project unknown
    at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1575)
    at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:506)
    at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200)
    at org.apache.maven.DefaultMaven.getProject(DefaultMaven.java:632)
    at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:515)
    at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:588)
    at org.apache.maven.DefaultMaven.getProjects(DefaultMaven.java:419)
    … 12 more
    Caused by: java.io.FileNotFoundException: /home/hardik/projects/ActionBazaar/site (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.&lt;init>(FileInputStream.java:106)
    at hidden.org.codehaus.plexus.util.xml.XmlReader.&lt;init>(XmlReader.java:124)
    at hidden.org.codehaus.plexus.util.xml.XmlStreamReader.&lt;init>(XmlStreamReader.java:67)
    at hidden.org.codehaus.plexus.util.ReaderFactory.newXmlReader(ReaderFactory.java:118)
    at org.apache.maven.project.DefaultMavenProjectBuilder.readModel(DefaultMavenProjectBuilder.java:1570)
    … 18 more
    [INFO] ————————————————————————
    [INFO] Total time: < 1 second
    [INFO] Finished at: Thu Jul 09 18:44:31 CEST 2009
    [INFO] Final Memory: 1M/4M
    [INFO] ————————————————————————

     
    • Eduardo 6:50 pm on August 2, 2010 Permalink | Reply

      Precisa executar o Maven 2 Eclipse (M2Eclipse) para fazer o maven apontar corretamente para os jars

    • Eduardo 6:51 pm on August 2, 2010 Permalink | Reply

      Need to run the Maven 2 Eclipse (M2Eclipse) to make the point maven correctly for the jars.

    • Jijo 9:32 pm on April 17, 2011 Permalink | Reply

      In every module or project in the workspace make sure the and the element in the pom.xml contain the same entries. In this example below it is ad-common. With this it should work.

      ad-common
      jar
      0.0.1-SNAPSHOT
      ad-common

  • hardikmehta 10:37 am on June 29, 2009 Permalink | Reply
    Tags: , eclipse-plugin, galileo, glassfish,   

    Glassfish plugin on Eclipse 3.5 (Galileo) 

    Eclipse 3.5 also called Galileo is out. I tried to install the glassfish application server plugin with the standard method described here, but it failed with the following error message

    
    session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Collect, operand=, action=).
    No repository found containing: osgi.bundle,com.sun.enterprise.jst.server.sunappsrv,1.0.28
    No repository found containing: org.eclipse.update.feature,com.sun.enterprise.jst.server.sunappsrv.feature,1.0.28
    
    

    After searching a lot I found a way to install it using the update site http://ajax.dev.java.net/eclipse, like any other plugin. This worked well.

    May be the problem is temporary and after sometime the standard way will also start working.

     
    • rosdi 3:45 am on July 3, 2009 Permalink | Reply

      Thanks! It works like charm! Gracias!

      • hardikmehta 6:20 pm on July 3, 2009 Permalink | Reply

        Nice to know the information is useful.

    • Aaron 9:07 pm on July 3, 2009 Permalink | Reply

      Thanks, it worked :D

    • salim 2:53 pm on July 7, 2009 Permalink | Reply

      it\’s really easy and it works well.
      thanks a lot.

    • ahsan 6:31 pm on July 7, 2009 Permalink | Reply

      it worked! thank you for your post.

    • Mladen 3:05 pm on July 11, 2009 Permalink | Reply

      Thanks a lot

    • Ramkumar 6:33 pm on July 25, 2009 Permalink | Reply

      Great! Thanks for the post.

    • merv 6:28 pm on July 26, 2009 Permalink | Reply

      Hey, thanks – this worked well :-)

    • lukibill 2:06 pm on August 8, 2009 Permalink | Reply

      Thanks a lot, i spent a lot time for this problem

      But when i read your article , everything work well

    • druka 3:40 pm on August 17, 2009 Permalink | Reply

      God bless you!

    • hithesh 7:37 pm on August 18, 2009 Permalink | Reply

      thanks so much.

    • Henrique Otavio 11:01 pm on August 18, 2009 Permalink | Reply

      Tanks !!!

    • LewP 7:00 pm on September 15, 2009 Permalink | Reply

      I installed the lastest Glassfish, then Galileo 3.5. Then added the v3 Prelude Server into Eclipse. All kind of jars, etc. missing.

      When I downloaded the Glassfish/Eclipse bundle…no problems.

      Any ideas? Not to fond of bundles..

      • hardikmehta 7:15 pm on September 15, 2009 Permalink | Reply

        It would help to see the error message or at least the jars which are missing,

    • Joe Vacha 3:57 am on December 2, 2009 Permalink | Reply

      thanks a lot – this worked well :-)

    • Seva 2:54 pm on December 7, 2009 Permalink | Reply

      Thanks, it worked out.

    • Konstantin 6:04 pm on December 11, 2009 Permalink | Reply

      It doesn’t work!!!

      ERROR:
      Cannot complete the install because one or more required items could not be found.
      Software currently installed: GlassFish Java EE 5, Java EE 6 1.0.44 (com.sun.enterprise.jst.server.sunappsrv.feature.feature.group 1.0.44)
      Missing requirement: Sun Application Servers and GlassFish Servers support 1.0.44 (com.sun.enterprise.jst.server.sunappsrv 1.0.44) requires ‘bundle org.eclipse.jst.jee.web 1.0.100′ but it could not be found
      Cannot satisfy dependency:
      From: GlassFish Java EE 5, Java EE 6 1.0.44 (com.sun.enterprise.jst.server.sunappsrv.feature.feature.group 1.0.44)
      To: com.sun.enterprise.jst.server.sunappsrv [1.0.44]

      • Konstantin 1:08 pm on December 14, 2009 Permalink | Reply

        Additionaly: I’ve used a minimal eclipse galileo 3.5.1 installation plus the j2ee plugin. Which plugin do I also have to install?

    • SAMK 8:31 am on May 27, 2010 Permalink | Reply

      Thanks a lot it worked!

    • uni 8:48 am on December 6, 2011 Permalink | Reply

      terima kasih banyak atas bantuannya. thank’s a lot ^_^

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
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: