All Downloads are FREE. Search and download functionalities are using the official Maven repository.

notify.osd.OsdNotifier Maven / Gradle / Ivy

There is a newer version: 0.6
Show newest version
package notify.osd;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import notify.MessageType;
import notify.Notifier;
import notify.UnableToNotifyException;

/**
 * Notify OSD Implementation for Ubuntu
* Requires notify-send commmand
* sudo apt-get install libnotify-bin
* http://archive.ubuntu.com/ubuntu/pool/universe/libn/libnotify4/libnotify- bin_0.7.2-0ubuntu2_amd64.deb
* * http://www.barregren.se/blog/pop-notification-command-line * * * @author francois wauquier * */ public class OsdNotifier implements Notifier { @Override public boolean isSupported() { try { return Runtime.getRuntime().exec("notify-send --help > nil").waitFor() == 0; } catch (Exception e) { return false; } } @Override public void notify(MessageType messageType, String title, String message) { List command = new ArrayList(); command.add("notify-send"); switch (messageType) { case NONE: break; default: command.add("-i"); command.add("gtk-dialog-" + messageType.name().toLowerCase()); } command.add(title); command.add(message); try { Runtime.getRuntime().exec(command.toArray(new String[command.size()])); } catch (IOException e) { throw new UnableToNotifyException("Unable to notify with Notify OSD", e); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy