Suggestion: Minimize to System Tray
I was wondering if it would be a possibility to add the functionality to minimize to system tray, like other programs do. There is a library called tray-item for rust that already implements this functionality with cross-compatibility, and it would be a great way to track the status of the application and open or exit it, without needing the full program in Windows. In Linux there is the daemon mode but I think a tray icon would allow for easy exiting the application. I'm not particularly fluent in Rust but I could try to help developing this feature.
I dont know much about how tray icons work, so I have to look that up. If you want to work on this, here is some information that might be helpful:
There are two components: The GUI and the daemon. The GUI checks if it can connect to an existing daemon on startup and if that is not the case, it executes the daemon as a child process.
Running lan-mouse daemon simply does not open a GUI and instead launches the daemon directly.
I would assume its best if the daemon process "owns" the tray icon but I'm not sure how the GUI would interact with that. It could probably just exit as normal keeping the daemon running in the background.
What I wanted to look into as well is the xdg background portal, which would integrate better with GNOME.
I very much would like to have this as a feature, because I don't like my workspace to be cluttered with unnecessary windows while I'm working. I'm going to give it a shot.
Things I've learned so far:
- The Linux ecosystem concerning tray icons is quite a mess.
- GNOME by default doesn't support systray icons. You need an extension
- GTK3 provides an API for tray icons, but due to the mess of the ecosystem it was completely removed from GTK4.
- The most up-to-date project for implementing systrays is
libayatana-appindicato-glib, which is a rewrite oflibayatana-appindicator, which is based onlibappindicatorby Ubuntu. - The most popular (cross-platform) Rust crate
tray-iconuses GTK3 under the hood, which is deprecated. The migration to GTK4 is ongoing. Compiling a GTK4 app withtray-icongives freaky runtime errors. - The ksni Rust crate looks very promising, but it is limited to Linux
I'm considering writing a minimal cross-platform Rust tray icon libary based on what I've found.
From what I have read, I think it's best to base an implementation of a systray on tray-icon, which is currently blocked by this pull request (and others). I've created a fork but I'm unsure whether some hidden GTK3 dependency in muda will screw things up.
While a tray solution would be great to have a visual indication that the process is running (and for quick context-menu actions), a shorter-term solution might be to spawn the daemon from the GUI in a way that keeps it alive when the GUI is closed. The lack of tray icon means that the daemon is left running invisibly, but opening a GUI again will connect again to that daemon for control, just like the tray would allow.
Alternatively, a systemd user-service file could be used to run (automatically) the daemon.