JLibnotify

Java binding for the native GNOME libnotify library, built on JNA. It lets a JVM application raise desktop notifications on Linux without shelling out to notify-send.

The binding is based on the IntelliJ LibNotify wrapper and on the notification module of OpenBeans.

Requirements

  • Java 8 or later. The library is compiled for Java 8 and has no dependency other than JNA.
  • Linux with libnotify installed. The shared library libnotify.so.4 is loaded at runtime, so the library does not work on macOS or Windows; on those platforms loading fails with a JLibnotifyLoadException. On Debian and Ubuntu the library comes in the libnotify4 package.
  • A running notification server to actually display the notifications. Reading the server information and its capabilities also needs one, since both answer over D-Bus.

Installing

Maven:

<dependency>
    <groupId>es.blackleg</groupId>
    <artifactId>jlibnotify</artifactId>
    <version>1.3.0</version>
</dependency>

Gradle:

implementation group: 'es.blackleg', name: 'jlibnotify', version: '1.3.0'

Releases are published to Maven Central.

Getting started

JLibnotify jLibnotify = DefaultJLibnotifyLoader.init().load();
jLibnotify.init("My Application");
jLibnotify.createNotification("Summary", "Body", "dialog-information").show();
jLibnotify.unInit();

The usage page covers the full lifecycle, error handling and how to query the notification server; the Javadoc documents every type of the API.

License

Released under the Apache License, Version 2.0.