flowkeeper-org / fk-desktop

Flowkeeper desktop application
GNU General Public License v3.0
23 stars 1 forks source link

Make the app only allow one instance #50

Open alexjp opened 3 days ago

alexjp commented 3 days ago

Hi,

I was trying to make a keyboard shortcut for Flowkeeper, to launch it initially and after that, to open the main window instead of going to the tray to open it.

But launching Flowkeeper after it is running, opens another instance of the application.

Could it instead open the main window of the running instance?

Thanks!

co-stig commented 3 days ago

Yes, it is doable, and I'll add a Setting for it. It will allow a single instance by default, I think.

Having said that, multiple instances is a feature. Even with the local file as the data source (default), Flowkeeper should "synchronize" user actions across its instances, as long as you enable "watch file for changes" in the Settings. For example, if you create a new task, it will write a line to ./flowkeeper-data.txt, and other Flowkeeper instances will detect it, read this file and update their state, as if the action happened locally. I admit that while it looks cool, it is completely useless :)

[note for myself] The "single instance" logic can be implemented via locking files or sockets, e.g. https://github.com/pycontribs/tendo/blob/main/src/tendo/singleton.py

alexjp commented 3 days ago

For example, if you create a new task, it will write a line to ./flowkeeper-data.txt, and other Flowkeeper instances will detect it, read this file and update their state, as if the action happened locally. I admit that while it looks cool, it is completely useless :)

I saw that option and suspected that it would come handy for using the data either through ssh/nfs/smb or a sync service, right? I do have a local server and also a laptop, so it is something I am meaning to explore later.

I worked around it on hyprland, using pyprland scratchpads (pressing, vim style, meta, then space, then k will show the Flowkeeper main window). But on kde, I don't how I would work around it. (and I am only on hyprland recently, and although loving it, don't know if I will permanently change to it)

co-stig commented 3 days ago

I saw that option and suspected that it would come handy for using the data either through ssh/nfs/smb or a sync service, right?

Exactly! It was an attempt to implement a rudimentary data sync mechanism which doesn't require a dedicated server. Tbh, I've never tried it with something like Google Drive or Dropbox, but I don't see why it wouldn't work.