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

[Tray] iwgtk indicator fails to display and errors out ironbar #645

Open
JonasVerhofste opened this issue Jun 21, 2024 · 7 comments
Open
Labels
bug Something isn't working
Milestone

Comments

@JonasVerhofste
Copy link

Describe the bug
When running iwgtk with indicator support, ironbar does not show the tray icon and throws an error. I'm pretty sure this is unrelated to other tray-related issues, as other tray applications work fine. Running with IRONBAR_LOG=debug gives me the following relevant output:

2024-06-20T23:41:31.183938Z DEBUG dispatch_message{msg=Msg { type: MethodCall, sender: UniqueName(Str(Borrowed(":1.172"))), path: ObjectPath("/StatusNotifierWatcher"), iface: InterfaceName(Str(Borrowed("org.kde.StatusNotifierWatcher"))), member: MemberName(Str(Borrowed("RegisterStatusNotifierItem"))), body: Signature("s") }}:dispatch_method_call{msg=Msg { type: MethodCall, sender: UniqueName(Str(Borrowed(":1.172"))), path: ObjectPath("/StatusNotifierWatcher"), iface: InterfaceName(Str(Borrowed("org.kde.StatusNotifierWatcher"))), member: MemberName(Str(Borrowed("RegisterStatusNotifierItem"))), body: Signature("s") }}:dispatch_method_call_try{msg=Msg { type: MethodCall, sender: UniqueName(Str(Borrowed(":1.172"))), path: ObjectPath("/StatusNotifierWatcher"), iface: InterfaceName(Str(Borrowed("org.kde.StatusNotifierWatcher"))), member: MemberName(Str(Borrowed("RegisterStatusNotifierItem"))), body: Signature("s") }}: system_tray::dbus::status_notifier_watcher: 73: registered item: org.kde.StatusNotifierItem-29555-1 | :1.172
2024-06-20T23:41:31.184169Z DEBUG system_tray::client: 127: received new item: :1.172org.kde.StatusNotifierItem-29555-1
2024-06-20T23:41:31.184358Z ERROR system_tray::client: 240: Error fetching properties from :1.172org.kde.StatusNotifierItem-29555-1/StatusNotifierItem: ServiceUnknown("The name is not activatable")

As far as I understand it (and I could be horribly wrong), the StatusNotifierItem API that is mentioned in the iwgtk README, is the freedesktop standard that the kde libappindicator protocol implements? So in theory, iwgtk and ironbar should be compatible?
However, I'm not sure if the above problem here lies with ironbar, a library used by ironbar or the way iwgtk advertises itself. In case of the latter two I'll create issues in the relevant repo and this can be closed.

To Reproduce

Expected behavior
The iwgtk icon shows up in the tray

System information:

  • Distro: Arch Linux
  • Compositor: Hyprland v0.41.1
  • Ironbar version: git main (a9d728f at the time of writing)
@JonasVerhofste JonasVerhofste added the bug Something isn't working label Jun 21, 2024
@JakeStanger
Copy link
Owner

JakeStanger commented Jun 28, 2024

However, I'm not sure if the above problem here lies with ironbar, a library used by ironbar or the way iwgtk advertises itself. In case of the latter two I'll create issues in the relevant repo and this can be closed.

I've not investigated yet, but here's what I do know:

  • The protocol is AWFUL. Absolutely dreadful, poorly defined, and every implementation varies.
  • Ironbar's implementation is not entirely spec-compliant. There's a few weird edge cases I need to sort, which is causing a lot of the reported tray issues.

My litmus test tends to be "does it work properly in another tray impl?" For example, all of Waybar, AGS and Quickshell have more correct implementations. A tray icon's behaviour there will confirm whether it's Ironbar or not.

@JonasVerhofste
Copy link
Author

JonasVerhofste commented Jun 28, 2024

Installed waybar to test and can confirm that it seems to work properly there (including changing icon images depending on wifi state). So that sadly increases the odds of it being ironbar.

I'll see if I can figure out where exactly it goes wrong. My brain however doesn't fully agree with rust (yet), so it'll take a bit for my head to wrap around the issue.

@JakeStanger
Copy link
Owner

No worries if you can't get anywhere, it's not an easy task. If you do want to give it a go though, the tray impl is here: https://github.com/JakeStanger/system-tray

@JonasVerhofste
Copy link
Author

JonasVerhofste commented Jun 28, 2024

Aha, that's what I was missing! Not being used to the rust ecosystem I had not seen that the implementation lived elsewhere.
You want me to close this issue and create one there?

@JakeStanger
Copy link
Owner

Happy to keep it here

@bwidawsk
Copy link

bwidawsk commented Jul 22, 2024

I have little clue how dbus works but I took a look at this because I'd also like this functionality. I learned two small pieces of information

  1. If you run ironbar AND THEN waybar, iwgtk -i will not work properly. Like ironbar changes the name or consumes the event first??
  2. The destination/path seems to be messed up because there is no separator between the bus and the path (ie. I think a . is missing). I did fix this but it didn't actually improve anything.

Here is a poor implementation to fix the second one. I'm happy to actually fix this properly, I just don't want to learn the dbus stuff :)

diff --git a/src/client.rs b/src/client.rs
index 6a17554b5d0e..4554bb7d0314 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -7,7 +7,6 @@ use crate::error::Error;
 use crate::item::{self, Status, StatusNotifierItem};
 use crate::menu::TrayMenu;
 use dbus::DBusProps;
-use std::borrow::Cow;
 use std::collections::HashMap;
 use std::sync::{Arc, Mutex};
 use std::time::{SystemTime, UNIX_EPOCH};
@@ -172,11 +171,14 @@ impl Client {
         tx: broadcast::Sender<Event>,
         items: Arc<Mutex<State>>,
     ) -> crate::error::Result<()> {
-        let (destination, path) = address
-            .split_once('/')
-            .map_or((address, Cow::Borrowed("/StatusNotifierItem")), |(d, p)| {
-                (d, Cow::Owned(format!("/{p}")))
-            });
+        let org_ndx = address.find("org").unwrap();
+
+        let mut destination = address.to_owned();
+        let path = destination.split_off(org_ndx);
+        let separator: &str = &path[3..4];
+        let destination = destination.trim_end_matches(['/', '.']);
+        let path = format!("{}{}", separator, path);
+        let path = path.replace(".", "/");
 
         let properties_proxy = PropertiesProxy::builder(&connection)
             .destination(destination.to_string())?
@@ -184,7 +186,7 @@ impl Client {
             .build()
             .await?;
 
-        let properties = Self::get_item_properties(destination, &path, &properties_proxy).await?;
+        let properties = Self::get_item_properties(&destination, &path, &properties_proxy).await?;
 
         items
             .lock()

@JakeStanger JakeStanger added this to the 0.16.1 milestone Aug 10, 2024
@JakeStanger
Copy link
Owner

Hello, I'm finally looking at picking this up. Unfortunately I can't even get iwgtk to start at the minute.

The above patch only works if the address has org in it, which a lot don't, causing it to crash. I'm sure it's a good start though, so as soon as I can get the thing to work I'll see if I can work it into the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants