Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fnune opened this issue May 19, 2021 · 11 comments · Fixed by #532
Closed

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

fnune opened this issue May 19, 2021 · 11 comments · Fixed by #532

Comments

@fnune
Copy link
Contributor

fnune commented May 19, 2021

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!

@amrbashir
Copy link
Member

amrbashir commented May 27, 2021

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.

@BenJeau
Copy link

BenJeau commented Apr 18, 2022

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

@amrbashir
Copy link
Member

(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.

@BenJeau
Copy link

BenJeau commented Apr 19, 2022

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.

@fnune
Copy link
Contributor Author

fnune commented Dec 13, 2022

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.

@amrbashir
Copy link
Member

amrbashir commented Dec 13, 2022

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.

@fnune
Copy link
Contributor Author

fnune commented Dec 14, 2022

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
Copy link
Contributor Author

fnune commented Dec 14, 2022

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!

@FabianLars
Copy link
Member

FabianLars commented Dec 14, 2022

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.

@amrbashir
Copy link
Member

this is now being implemented in tauri-apps/tray-icon#11, it will not be implemented in tao

@amrbashir
Copy link
Member

amrbashir commented Jan 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants