tao icon indicating copy to clipboard operation
tao copied to clipboard

Implement ability to show text in the system tray/menu bar

Open fnune opened this issue 3 years ago • 4 comments

Use case: apps like MeetingBar show text instead of a system tray icon.

image

I'd love the ability to do this with Tauri:

  • Show text instead of the system tray icon, and be able to update it during runtime.
  • Show text next to the system tray icon.

However, I'm not sure if this is even possible in other operating systems. With that in mind, maybe it doesn't fit Tauri's philosophy to add a feature that will only work on macos!

fnune avatar May 19 '21 09:05 fnune

On windows they are called deskbands, they don't live in the system tray exactly but rather next to it.

Edit: Looks like Deskbands will not be supported in Windows11 :sad:, and AFAIK not possible at all in Linux, so this feature will be only for macOS.

amrbashir avatar May 27 '21 09:05 amrbashir

I would be greatly interested in setting text for the systray on macos, I've been looking in the rust community a crate for the system tray, with this one https://github.com/olback/tray-item-rs/blob/master/src/api/macos/mod.rs, you can set a title (and for linux it just set it as the id and for windows set the tooltip) - just wanted to point out how it's implemented there

BenJeau avatar Apr 18 '22 20:04 BenJeau

(and for linux it just set it as the id and for windows set the tooltip)

'Tooltips" on Windows and "Id" on Linux is not the same as showing text instead of the icon. Windows and Linux, don't need to have this feature anyway, it can be macOS only.

amrbashir avatar Apr 19 '22 00:04 amrbashir

I totally agree with your statement, they are not equivalent of showing text - was just stating what another crate is doing, alongside a possible macos implementation of showing text in the system tray/menu bar (they are using setTitle_(title) on the status item at https://github.com/olback/tray-item-rs/blob/master/src/api/macos/mod.rs#L131).

Let me come up with a PR for setting the title.

BenJeau avatar Apr 19 '22 01:04 BenJeau

Wondering if this is possible for Linux also. I'd want it for my WIP app. From searching the webs I can't really figure out whether it's possible or not. My best attempt was this search:

https://github.com/search?q=repo%3AAyatanaIndicators%2Flibayatana-appindicator%20label&type=code

This search is also interesting: https://wiki.ayatana-indicators.org/SystemComponents

image

I'm not sure if I'm looking at the right things.

fnune avatar Dec 13 '22 23:12 fnune

Unfortunately, not possible, at least with the old libappindicator (which we still use on some distros) as for the newer app indicator libayatana-appindicator, there is virtually no good documentation available.

amrbashir avatar Dec 13 '22 23:12 amrbashir

I'm having trouble finding documentation, too :( the best I could find were the Rust bindings for it https://docs.rs/libayatana-appindicator

Note that it does have a set_label option: https://docs.rs/libayatana-appindicator/latest/libayatana_appindicator/struct.AppIndicator.html#method.set_label

fnune avatar Dec 14 '22 08:12 fnune

I managed to build a PoC using libayatana and GTK:

gtk::init().unwrap();
                                                                     
let mut indicator = AppIndicator::new("some-name", "");
indicator.set_status(AppIndicatorStatus::Active);
indicator.set_label(" This will display next to the icon", "");
                                                                     
let icon_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("icons");
indicator.set_icon_theme_path(icon_path.to_str().unwrap());
indicator.set_icon_full("icon", "icon");

image

So it's possible!

fnune avatar Dec 14 '22 11:12 fnune

Now the only problem left is that ayatana is basically only existent on debian/ubuntu 😅 Most of the other distros, and flatpaks, still use libappindicator.

Edit: nvm, libappindicator does seem to have a set_label function too.

FabianLars avatar Dec 14 '22 11:12 FabianLars

this is now being implemented in https://github.com/tauri-apps/tray-icon/pull/11, it will not be implemented in tao

amrbashir avatar Jan 09 '23 17:01 amrbashir

Just a heads up, I am testing on KDE and the text is not showing, so after some digging in the source code of libappindicator I found the label documentation.

A label that can be shown next to the string in the application
indicator.  The label will not be shown unless there is an icon
as well.  The label is useful for numerical and other frequently
updated information.  In general, it shouldn't be shown unless a
user requests it as it can take up a significant amount of space
on the user's panel.  This may not be shown in all visualizations.

So you shouldn't rely on it for critical information.

amrbashir avatar Jan 10 '23 13:01 amrbashir