ags icon indicating copy to clipboard operation
ags copied to clipboard

Does it support Java?

Open sblantipodi opened this issue 1 year ago • 4 comments

as title.

does this supports Java?

It seems that this method returns false: SystemTray.isSupported()

and that Java launch an exception when trying to initialize the TrayIcon:

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsupportedOperationException: The system tray is not supported on the current platform.
	at java.desktop/java.awt.SystemTray.getSystemTray(Unknown Source)
	at org.dpsoftware.gui.TrayIconManager.initTray(TrayIconManager.java:237)
	at org.dpsoftware.FireflyLuciferin.start(FireflyLuciferin.java:261)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
	at java.base/java.security.AccessController.doPrivileged(Unknown Source)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:264)
	... 1 more

sblantipodi avatar Sep 25 '24 22:09 sblantipodi

Can't say for sure, I don't see anywhere mentioned on that page what protocol it uses and I don't know enough about java to know where to look for its source code

Aylur avatar Sep 25 '24 23:09 Aylur

ags uses the StatusNotifierItem protocol for the tray, which seems not to be supported by java.awt.SystemTray. Another way to implement tray icons was by using xembeds (this is rarely used nowadays. Almost all apps moved over to sni). So you could give xembed-sni-proxy a try. But that requires your app to run in xwayland (I guess. Does javafx even support Wayland? Idk).

But I'm sure someone implemented support for sni in java somewhere. So maybe try another lib for the tray.

kotontrion avatar Sep 26 '24 05:09 kotontrion

Sure JavaFX supports wayland no problem. On the latest Ubuntu 24 LTS I can use my program with both GNOME (X11 and Wayland) and KDE (Plasma).

what is the difference between the Ubuntu tray implementaton and ags?

sblantipodi avatar Sep 26 '24 13:09 sblantipodi

I quickly looked at the source code of java.awt.SystemTray. As i guessed earlier, it does not support the sni protocol, it uses xembeds. running xembed-sni-proxy results in SystemTray.isSupported() to be true. (I didn't implement a full tray icon test app though)

xembed-sni-proxy is part of plasma-workspace, so it works on kde, gnome has probably something similar implemented.

kotontrion avatar Sep 26 '24 13:09 kotontrion