how do i make a compose desktop (JVM) app only eve...
# compose-desktop
z
how do i make a compose desktop (JVM) app only ever start 1 instance? is there a proper way of doing this?
s
you can bind your instances to a single port or lock via files to check if another instance is already running
@S. Opening a port will trigger the Windows firewall, so you need to use a lockfile. That’s what I do in my library.
z
nice. but its seems sadly compose can not do it out of the box? without native compiled code
can i rip out the parts with a lockfile in your code? would you point me to it?
z
cool thanks
just tried your lib, sadly on vanilla debian there is no tray at all in the OS. so any apps with tray just dont work like expected. oh well debian ...
s
@אליהו הדס yeah that's right, locking via files is a bit cleaner. it was easier to implement to handle deep links and only asks for permissions once, so that's fine for now. my ideal solution would still be a native launcher to get rid of the jvm delay for deep links
u
@S. You can also display a splash screen.
s
yeah but the problem is that the jvm splash screen shows for every new deep link
z
still awesome lib
u
@S. Yes, I know, it's problematic. I haven't found a solution for it, and I don't have time to create a native launcher.
Actually, I think that under Windows, it would be possible to prevent the splash screen image from being read via JNA, and therefore the second instance wouldn't display it because it wouldn't be able to read it.
That seems much simpler to me, but I think it would only work under Windows.
@Zoff Does your system support trays? Because vanilla GNOME requires an extension.
s
oh interesting. macos doesn't have this problem (and I don't publish for linux), it's only windows for me
u
Yes, macOS by default only allows one instance
😯 1
@S. It's a bit hacky, but I think it will work.
s
there also seems to be a provided solution in the WinRT sdk https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.windows.[…]e.appinstance.findorregisterforkey?view=windows-app-sdk-1.8 but I don't know if and how it's possible to use that
u
It also requires a native launcher.
z
no my system does not support trays. but your SingleInstanceManager.kt worked like a charm. thanks so much for that
👍 1
just used a random UUID as app identifier