ags icon indicating copy to clipboard operation
ags copied to clipboard

Restarting AGS breaks the system tray/systray

Open GabeDuarteM opened this issue 1 year ago • 1 comments

This is hard to reproduce since it doesn't always happen, but sometimes when I restart ags the systray doesn't ever launch again until I reboot the system. I can launch other system trays apps (like stalonetray for example), and it shows the app icons normally, but when I launch ags it just tells me Another system tray is already running, and refuses to run. This doesn't always happen, and I couldn't figure out what triggers it.

The systray module I use is the following:

function SysTray() {
  const items = systemtray.bind("items").as((items) =>
    [
      Widget.Button({
        className: "sys-tray-item tray-custom-icon",
        on_primary_click: () => {
          Utils.exec(`swaync-client --toggle-panel`)
        },
        on_secondary_click: () => {
          Utils.exec(`swaync-client --toggle-dnd`)
        },
        label: "",
        setup: self => self.hook(NotificationInfo, () => {
          if (NotificationInfo.value === null) {
            return;
          } else if (NotificationInfo.value.inhibited || NotificationInfo.value.dnd) {
            self.label = "";
          } else {
            self.label = "";
          }
        }),
      }),
      ...items.map((item) =>
        Widget.Button({
          className: "sys-tray-item",
          child: Widget.Icon({ icon: item.bind("icon") }),
          on_primary_click: (_, event) => item.activate(event),
          on_secondary_click: (_, event) => item.openMenu(event),
          tooltip_markup: item.bind("tooltip_markup"),
        }),
      )
    ],
  );

  return Widget.Box({
    children: items,
  });
}

Nothing out of the ordinary IMO, but the full config is also available here. Is this a common problem? Any ideas how to debug this? ags -q doesn't help (ags is not running at all when this happens, until I of course launch it), and this only happens with AGS, and only when I restart it, so I assume either ags is not properly disposing of the tray sometimes, or the tray-detection of ags is broken (since I can still launch stalonetray, for example). The video attached shows the behaviour happening, and how I can still launch other systrays

https://github.com/user-attachments/assets/8a2f238d-0f46-4b0c-9e0f-bd6fa9a3020b


This is very annoying when I'm developing, since I'm constantly restarting ags (since ags doesn't have hot-reload builtin), and because of that, I also need to keep restarting my computer to see my changes, which is a terrible UX :sweat_smile:

GabeDuarteM avatar Sep 04 '24 10:09 GabeDuarteM

I experience this issue too, although waybar has the same problem for me (tray launches on login once only), so i suspect the issue lies elsewhere, (not an ags/waybar problem).

btw you can just logout/kill your wm, you dont need to restart the machine. Let me know if you figure it out/solve it :)

prometheaus avatar Oct 04 '24 09:10 prometheaus

Hi @Aylur, this unfortunately is still an issue for me and for others too, its one of the main reasons why I just left my AGS config as is and haven't further developed it... Is there a specific reason for it to have been closed as not planned? :/

GabeDuarteM avatar Nov 13 '24 22:11 GabeDuarteM

https://github.com/Aylur/ags/pull/504

Aylur avatar Nov 13 '24 23:11 Aylur

ahhh, got it, I'll check if on a v2 setup this still happens, thanks!

GabeDuarteM avatar Nov 13 '24 23:11 GabeDuarteM