43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
|
package eu.mikroskeem.notificationhackery;
|
||
|
|
||
|
import eu.mikroskeem.notificationhackery.linux.LibNotify;
|
||
|
import eu.mikroskeem.notificationhackery.windows.WindowsNotification;
|
||
|
|
||
|
import java.util.concurrent.ExecutorService;
|
||
|
import java.util.concurrent.Executors;
|
||
|
|
||
|
public class Main {
|
||
|
private static ExecutorService ex = Executors.newCachedThreadPool();
|
||
|
|
||
|
public static void main(String... args){
|
||
|
String osname = System.getProperty("os.name");
|
||
|
eu.mikroskeem.notificationhackery.INotificationBackend backend = null;
|
||
|
if(osname.startsWith("Windows")){
|
||
|
try {
|
||
|
backend = new WindowsNotification();
|
||
|
} catch (Exception e){
|
||
|
System.out.println("Tray not supported");
|
||
|
}
|
||
|
} else if (osname.startsWith("Linux")){
|
||
|
try {
|
||
|
backend = new LibNotify();
|
||
|
} catch (Exception e){
|
||
|
System.out.println("Failed to initialize Libnotify binding");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(backend != null) {
|
||
|
backend.sendNotification("wolo", "lolo");
|
||
|
final INotificationBackend finalBackend = backend;
|
||
|
ex.submit(new Thread(()->{
|
||
|
try {
|
||
|
Thread.sleep(5000);
|
||
|
}
|
||
|
catch (InterruptedException ignored) {}
|
||
|
finalBackend.cleanup();
|
||
|
System.exit(0);
|
||
|
}));
|
||
|
}
|
||
|
}
|
||
|
}
|