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

SysTrayItem Click Problem #2

Open
kursatufukcoskun opened this issue Mar 6, 2024 · 3 comments
Open

SysTrayItem Click Problem #2

kursatufukcoskun opened this issue Mar 6, 2024 · 3 comments

Comments

@kursatufukcoskun
Copy link

kursatufukcoskun commented Mar 6, 2024

Hello Ahmed!

First of all, thank you very much for this excellent work.

I have a problem. An exception occurs when I click on some tray items. For example when I click to the bluetooth icon, it works and opens bluetooth manager application. But when I click on Spotify, NM Applet or Steam, an error occurs. The error is like this:

(com.github.Aylur.ags:377891): Gjs-CRITICAL **: 22:12:50.115: JS ERROR: TypeError: item.activate(...) is undefined SysTrayItem/onPrimaryClick/<@file:///home/kursatufukcoskun/.config/ags/modules/widgets/systray.js:26:14 setTimeout/source<@resource:///org/gnome/gjs/modules/esm/_timers.js:72:9 _init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

(com.github.Aylur.ags:377891): Gjs-WARNING **: 22:12:50.954: Unhandled promise rejection. To suppress this warning, add an error handler to your promise chain with .catch() or a try-catch block around your await expression. Stack trace of the failed promise: @resource:///org/gnome/gjs/modules/core/overrides/Gio.js:192:20 activate@resource:///com/github/Aylur/ags/service/systemtray.js:40:21 SysTrayItem/onPrimaryClick/<@file:///home/kursatufukcoskun/.config/ags/modules/widgets/systray.js:26:14 setTimeout/source<@resource:///org/gnome/gjs/modules/esm/_timers.js:72:9 _init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

Operating System: Arch Linux
AGS Version: 1.8.0

What do you think could be the problem? Thanks for your support.

@AhmedSaadi0
Copy link
Owner

I'm short on time right now, but I've managed to implement a temporary workaround for the issue.

What I did was incorporate a try-catch block. Now, when a click occurs, if the icon has an associated action, it will execute seamlessly. If not, it will do nothing without the error.

Also I added rx_path, tx_path to handle network speed meter in the settings file

hardware: {
        network: {
            rx_path: '/sys/class/net/wlp0s20f3/statistics/tx_bytes',
            tx_path: '/sys/class/net/wlp0s20f3/statistics/tx_bytes',
        },
    },

@kursatufukcoskun
Copy link
Author

Thank you for your answer.

But it didn't work for me.
2024-03-16-130643_hyprshot

@AhmedSaadi0
Copy link
Owner

Actually right now I did not find any solutions. Even after looking into other people's config, I found that they do not use item.activate(event); instead they make both mouse buttons open the menu of the systray icon
item.menu.popup_at_widget(btn, Gravity.SOUTH, Gravity.NORTH, null),

you can change that in the file modules/widgets/systray.js

    onPrimaryClick: (btn, event) => {
      try {
        item.activate(event).catch();
      } catch (TypeError) {}
    },
    onSecondaryClick: (btn) =>
      item.menu.popup_at_widget(btn, Gravity.SOUTH, Gravity.NORTH, null),

Into

    onPrimaryClick: (btn, event) => {
     item.menu.popup_at_widget(btn, Gravity.SOUTH, Gravity.NORTH, null),
    },
    onSecondaryClick: (btn) =>
      item.menu.popup_at_widget(btn, Gravity.SOUTH, Gravity.NORTH, null),

For me I'll stick with the original settings as they error only appears in the log and does not crash anything, I just ignore the action if nothing happens and use the second mouse click.

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

No branches or pull requests

2 participants