I have a simple Python code that creates a Linux tray indicator with AppIndicator3 from GI. That works fine. But I would like to detect and handle a simple user click or a double-click on this tray icon.
From what I know, for example, Telegram uses Qt class QSystemTrayIcon, and it supports this functionality because Telegram window shows itself when user double-clicks the tray icon.
- I know AppIndicator3 supports
scroll_event
signal that triggers when the user scrolls mouse wheel over the tray icon.
Signaled when the
AyatanaAppIndicator3.Indicator
receives a scroll event.
- There is also a
set_secondary_activate_target(menuitem)
method that indicates there is somehow handled middle-click event.
Set the
menuitem
to be activated when a secondary activation event (i.e. a middle-click) is emitted over theAyatanaAppIndicator3.Indicator
icon/label.
Is there somebody who understands how it works? Both previous examples make me wonder why there is not a simple mouse click signal/event. I'm thinking if it could be possible to go deeper, maybe inherit AyatanaAppIndicator3.Indicator class and rewrite some event handling? Or maybe dig even deeper into StatusNotifierItem and Activate method, if it is what AppIndicator implements?
Or is there any tricky workaround for this? Because this seems to be an unanswered question for more than ten years and I am not satisfied with only the "It is not possible" answer.
I'm also aware I'm not the first one asking this question. I made small research and found multiple related threads:
Python AppIndicator bindings -> howto check if the menu is open?
How to run an action when clicking on an appindicator
How to program a one click indicator (add middle click functionality)?
indicator-application does not send signals when a menu is shown/hidden
handle click events and modifiers