Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
1.74k stars 95 forks source link

Strange behavior after suspend #396

Closed dangooddd closed 2 months ago

dangooddd commented 2 months ago

Very strange behavior in two cases of suspend: 1) if after suspend i wait few seconds (2 and more), ags working flawlessly 2) if i immediately press button after suspend, ags shows nothing on wake up, but works ("Ags with busname "ags" is already running"), to make bar showing again i need to fully reload ags

No errors occurs, tested with empty bar and bar from example. Fedora 39, hyprland 39.1

dangooddd commented 2 months ago

Also got strange messages from hypridle in case 2: image

dangooddd commented 2 months ago

UPDATE: bar windows crushes in any case. Suspend just makes bar invisible, "toggle-window" doesnt work. With example config i got those outputs image

dangooddd commented 2 months ago

So i figured out why i got problem like this.

What happens

I discovered that on suspend ags invokes .destroy for all windows in App.windows, but ags app is working fine. My guess is that on suspend my monitor is removed and hyprland "monitor-removed" event accurs, so ags kills all windows on that monitor.

How I fix that

That may be not the best solution, but i make this:

// config.js
const hyprland = await Service.import("hyprland")

// some config...

hyprland.connect("monitor-added", (_hypr, monitor) => {
    var id = -1
    for (var mt of hyprland.monitors) {
        if (mt.name == monitor)
            id = mt.id
            break;
    }
    id = id == -1 ? 0 : id

    var flag = true
    for (var wd of App.windows) {
        if (wd.name == `bar-${id}`)
            flag = false
            break;
    }

    if (flag)
        App.addWindow(Bar(id))
})

So this fix just run App.addWindow() if "monitor-added" signal occurs