What's the current status about notifications on L...
# compose-desktop
d
What's the current status about notifications on Linux? I've stumbled across https://github.com/JetBrains/compose-jb/issues/65, but it's more about the tray icon and some infos are older. Should the native notifications work right now? My current status: I tried it on my Ubuntu 20.04 (with gnome shell 3.36.9) and they aren't shown. Based on dbus-monitor they also aren't send to the OS. Tested it with the "old" version with
Notifier
and the experimental API with
TrayState
. Both with
0.4.0
and
0.5.0-build225
.
Copy code
fun main() = Window {
    val notifier = Notifier()
    val trayState = TrayState()

    MaterialTheme {
        Column {
            Button(onClick = {
                notifier.notify("Notification Notifier", "Hello there!")
            }) { Text("Send via Notifier") }

            Spacer(Modifier.height(8.dp))

            Button(onClick = {
                trayState.sendNotification(Notification("Notification TrayState", "Hello there!"))
            }) {
                Text("Send via TrayState")
            }
        }
    }
}
o
@Roman Sedaikin [JB] could you please take a look when possible?
r
Ok, I will look at that.
i
The current approach is to use Swing mechanism to send notifications. Swing can send them only using tray icon (the old
Notifier
just creates and removes temporary tray icon if there is no one; but it is a hack). We can look how to send notifications bypassing Swing, probably just using the native API's for that. In theory sending just a plain text shouldn't be much of a problem.
👍 2
d
Thanks for the quick answers. Just looked deeper into the
ui-desktop
package. The Notifier uses
SystemTray.isSupported()
which returns false as stated in the linked issue. So no wonder it didn't work 😉 I did experiment a little with the use of external programs like notify-send and will take a look into org.gnome.notify. For now not the most important topic (for me) on Compose Desktop. But would be great at some point.