Monday, May 6, 2013

Notify-send Java Class for Linux

Hi folk,

I will share this Java class that I use to display tools information on my Linux operating system.

Sample:




Notify-send is a little, simple On-Screen Display application. It uses the notify bubble pop-up Linux system.

 /**
 * Utils
 *
 * Created on Nov 25, 2010
 *
 * @version 1.0
 * @author Jorge Iglesias, (jorge.iglesias@es.ibm.com)
 *
 * @ Copyright IBM Software Services Rational Spain. 2011. All rights reserved.
 */

package com.ibm.issr.util.linux;

import java.io.IOException;

public class Notify {
  
    public static void sendInfo(String text) {
        send("info",text);
    }

    public static void sendError(String text) {
        send("error",text);
    }

    private static void send(String type, String text) {
        String[] command = new String[] { "notify-send", "-t", "20000", "-i", type, text };
        try {
            Runtime.getRuntime().exec(command);
        } catch (IOException e) {
            System.err.println(e.getMessage());
        }
    }
}


No comments:

Post a Comment