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

Clicking the Tribler icon on Ubuntu 22 doesn't do anything (running from source) #8084

Closed
qstokkink opened this issue Aug 2, 2024 · 7 comments

Comments

@qstokkink
Copy link
Contributor

qstokkink commented Aug 2, 2024

On Ubuntu 22.04.4 LTS the Tribler icon shows up but clicking (right or left) the icon does not show a context menu to open the browser.

@qstokkink qstokkink changed the title Clicking the Tribler icon on Ubuntu 22 doensn't do anything Clicking the Tribler icon on Ubuntu 22 doesn't do anything Aug 2, 2024
@qstokkink
Copy link
Contributor Author

qstokkink commented Aug 2, 2024

This might be https://github.com/moses-palmer/pystray/issues/ 20

It could also be this:

It will be displayed when the right-hand button has been pressed on the icon on Windows, and when the icon has been clicked on other platforms. Menus are not supported on X.

@qstokkink
Copy link
Contributor Author

To confirm:

>>> pystray.Icon.HAS_MENU
False

@qstokkink
Copy link
Contributor Author

qstokkink commented Aug 2, 2024

I added a quick workaround to make a press function like a click on "Open" in the menu.

diff --git a/src/run_tribler.py b/src/run_tribler.py
index 9200e6eb7..02209fe6d 100644
--- a/src/run_tribler.py
+++ b/src/run_tribler.py
@@ -92,6 +92,14 @@ async def main() -> None:
     menu = (pystray.MenuItem('Open', lambda: webbrowser.open_new_tab(url)),
             pystray.MenuItem('Quit', lambda: session.shutdown_event.set()))
     icon = pystray.Icon("Tribler", icon=image, title="Tribler", menu=menu)
+
+    import Xlib
+    old_dispatch = icon._message_handlers[Xlib.X.ButtonPress]
+    def dispatch_press(event):
+        old_dispatch(event)
+        webbrowser.open_new_tab(url)
+    icon._message_handlers[Xlib.X.ButtonPress] = dispatch_press
+
     threading.Thread(target=icon.run).start()

     await session.shutdown_event.wait()

@egbertbouman
Copy link
Member

Ideally, you'd want to use the appindicator backend. Have you tried running sudo apt install gir1.2-appindicator3-0.1?

@qstokkink
Copy link
Contributor Author

Have you tried running sudo apt install gir1.2-appindicator3-0.1?

I just tried: I still don't get a menu. I printed pystray.Icon.__module__ and it gave me pystray._xorg.

I figured I could force the matter using from pystray._appindicator import Icon. Then I got ModuleNotFoundError: No module named 'gi'.

Then I installed sudo apt install libgirepository1.0-dev and python -m pip install PyGObject. However, the latter (pip) failed because pycairo does not build in pip. I'll see if I can resolve that next week.

@qstokkink
Copy link
Contributor Author

At least the build works. I guess I'll downgrade this from a bug to a feature request, a "nice to have" for when I run from source.

@qstokkink qstokkink changed the title Clicking the Tribler icon on Ubuntu 22 doesn't do anything Clicking the Tribler icon on Ubuntu 22 doesn't do anything (running from source) Aug 6, 2024
@qstokkink qstokkink transferred this issue from qstokkink/TriblerExperimental Aug 8, 2024
@qstokkink
Copy link
Contributor Author

I think that fixing #8085 offers a workable workaround for this.

The only downside then is that closing the browser tab will make you "lose" Tribler and you'll have to manually invoke the GUI with the API key. However, when running from source, the Tribler process should be available from your terminal anyway to restore/kill.

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

No branches or pull requests

2 participants