Aylur / ags

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

Error: There is no window named <window_name> #310

Closed Zerodya closed 7 months ago

Zerodya commented 7 months ago

Whenever I try to toggle a new window (launcher in this example) from my Bar, I get the following error:

(com.github.Aylur.ags:146584): Gjs-Console-CRITICAL **: 22:09:38.906: Error: There is no window named launcher
getWindow@resource:///com/github/Aylur/ags/app.js:133:27
toggleWindow@resource:///com/github/Aylur/ags/app.js:108:24
on_clicked@file:///home/alpha/.config/ags/widgets/bar/Bar.js:21:9
Button/<@resource:///com/github/Aylur/ags/widgets/button.js:28:44
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

but I can't spot any issues in the code. Everything looks correct to me.

When I run ags I see my Bar correctly, but toggling other windows does not work, and running ags -t launcher returns undefined. This behaviour happens for every other widget as well.

These are the relevant configuration files (I got them here: https://github.com/chadcat7/crystal/tree/freosan) with comments on relevant parts:

config.js:

import App from 'resource:///com/github/Aylur/ags/app.js'
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'

import { bar } from "./widgets/bar/Bar.js"
import { launcher } from './widgets/launcher/Launcher.js'
import { panel } from "./widgets/panel/Panel.js"

import { calendarbox } from "./widgets/calendar/Calendar.js"
import { osd } from './widgets/popups/Osd.js'

import { wifimenu } from './widgets/popups/Wifi.js'
import { bluetoothmenu } from './widgets/popups/Bluetooth.js'

import { notif } from './widgets/popups/Notifications.js'

let loadCSS = () => {
  const scss = `${App.configDir}/style/_style.scss`
  const css = `${App.configDir}/finalcss/style.css`
  Utils.exec(`sassc ${scss} ${css}`)
  App.resetCss()
  App.applyCss(`${App.configDir}/finalcss/style.css`)
}

loadCSS()

Utils.monitorFile(
  `${App.configDir}/style/`,
  function() {
    loadCSS()
  },
  'directory',
)

// DEFAULT EXPORT
export default { windows: [bar, launcher, panel, calendarbox, osd, wifimenu, bluetoothmenu, notif], style: `${App.configDir}/finalcss/style.css` }

widgets/bar/Bar.js:

mport Widget from 'resource:///com/github/Aylur/ags/widget.js';
import App from 'resource:///com/github/Aylur/ags/app.js';
import Clock from "./mods/Clock.js"
import Status from "./mods/Status.js"
import Systray from "./mods/Systray.js"

const pfp = () => Widget.Button({
  child: Widget.Box({
    class_name: "bar-pfp",
    css: `background-image: url('${App.configDir}/assets/pfp.jpg');background-size: cover;`
  }),
  on_clicked: () => {
  }
})
const nixicon = () => Widget.Button({
  child: Widget.Icon({
    icon: `${App.configDir}/assets/nixos.png`,
    size: 25
  }),
  on_clicked: () => {
    App.toggleWindow("launcher") // THIS SHOULD TOGGLE LAUNCHER WINDOW
  }
})

const OptionalWorkspaces = async () => {
  try {
    return (await import('./mods/Workspaces.js')).default();
  } catch {
  }
};

const left = () => Widget.Box({
  spacing: 12,
  homogeneous: false,
  vertical: true,
  setup: async b => {
    b.children = [nixicon(), await OptionalWorkspaces() ]
  }
});

const right = () => Widget.Box({
  spacing: 12,
  homogeneous: false,
  vertical: true,
  vpack: "end",
  children: [Systray(), Status(), Clock(), pfp()]
});

const box = () => Widget.CenterBox({
  class_name: "bar",
  homogeneous: false,
  spacing: 8,
  vertical: true,
  start_widget: left(),
  end_widget: right(),
})

const bar = Widget.Window({
  name: 'bar',
  anchor: ['top', 'left', 'bottom'],
  exclusivity: "exclusive",
  margins: [0, 0, 0, 0],
  child: box(),
})

export { bar }

widgets/launcher/Launcher.js

import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import App from 'resource:///com/github/Aylur/ags/app.js';
import { exec } from 'resource:///com/github/Aylur/ags/utils.js'

import Weather from "./mods/Weather.js"
import AppLauncher from "./mods/AppLauncher.js"
import Music from "./mods/Music.js"
import Sites from "./mods/Sites.js"

const left = () => Widget.Box({
  class_name: "launcher-left",
  homogeneous: false,
  spacing: 12,
  vertical: true,
  vpack: "fill",
  vexpand: true,
  children: [
    Widget.Box({
      class_name: "launcher-left",
      homogeneous: false,
      spacing: 30,
      vertical: true,
      vpack: "end",
      vexpand: true,
      children: [

        Widget.Button({
          child: Widget.Label({
            class_name: 'launcher-exit',
            label: "󰐥",
            vpack: "center",
          }),
          on_clicked: () => {
            exec("poweroff")
          }
        }),
        Widget.Button({
          child: Widget.Label({
            class_name: 'launcher-exit',
            label: "󰦛",
            vpack: "center",
          }),
          on_clicked: () => {
            exec("reboot")
          }
        }),
        Widget.Button({
          child: Widget.Label({
            class_name: 'launcher-exit',
            label: "󰌾",
            vpack: "center",
          }),
          on_clicked: () => {
            App.toggleWindow("launcher")
            exec("waylock")
          }
        }),
        Widget.Box({
          class_name: "launcher-pfp",
          css: `background-image: url('${App.configDir}/assets/pfp.jpg');background-size: cover;`
        }),
      ],
    }),

  ]
})

const right = () => Widget.Box({
  class_name: "launcher-right",
  homogeneous: false,
  vertical: true,
  children: [
    Weather(),
    Sites(),
    Music(),
  ]
})
const box = Widget.Box({
  class_name: "launcher",
  homogeneous: false,
  vertical: false,
  children: [
    left(),
    AppLauncher(),
    right(),
  ]
})

const launcher = Widget.Window({
  name: 'launcher',
  popup: true,
  visible: false,
  focusable: true,
  anchor: ['top', 'left'],
  margins: [0, 0],
  child: box,
})

export { launcher } // THIS SHOULD EXPORT `launcher` CORRECTLY

This is the full ags output in terminal:


(com.github.Aylur.ags:146584): Gtk-WARNING **: 22:09:31.546: Theme parsing error: gtk.css:16:37: Missing semicolon at end of color definition

(com.github.Aylur.ags:146584): Gtk-WARNING **: 22:09:31.546: Theme parsing error: gtk.css:18:35: Missing semicolon at end of color definition

(com.github.Aylur.ags:146584): Gtk-WARNING **: 22:09:31.546: Theme parsing error: gtk.css:23:46: Missing semicolon at end of color definition

(com.github.Aylur.ags:146584): Gtk-WARNING **: 22:09:31.546: Theme parsing error: gtk.css:33:45: Missing semicolon at end of color definition

(com.github.Aylur.ags:146584): Gjs-Console-WARNING **: 22:09:31.745: Window.focusable is DEPRECATED, use Window.keymode

(com.github.Aylur.ags:146584): Gjs-Console-WARNING **: 22:09:31.784: Error: Stack.items is DEPRECATED, use Stack.children
set items@resource:///com/github/Aylur/ags/widgets/stack.js:71:26
_init/Gtk.Widget.prototype._init@resource:///org/gnome/gjs/modules/core/overrides/Gtk.js:59:50
_init@resource:///com/github/Aylur/ags/widgets/widget.js:90:15
Stack@resource:///com/github/Aylur/ags/widgets/stack.js:40:9
Stack@resource:///com/github/Aylur/ags/widget.js:35:43
default@file:///home/alpha/.config/ags/widgets/panel/mods/NotificationCenter.js:106:12
@file:///home/alpha/.config/ags/widgets/panel/Panel.js:13:36
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

(com.github.Aylur.ags:146584): Gjs-WARNING **: 22:09:31.834: JS ERROR: Error: directory passed as a parameter in `monitorFile`. Specifying the type is no longer required.
monitorFile@resource:///com/github/Aylur/ags/utils/file.js:61:15
@file:///home/alpha/.config/ags/config.js:29:7
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

Gjs-Console-Message: 22:09:31.900: Array []

(com.github.Aylur.ags:146584): Gtk-WARNING **: 22:09:35.901: Negative content width -35 (allocation 1, extents 18x18) while allocating gadget (node box, owner Ags_Box)

(com.github.Aylur.ags:146584): Gjs-Console-CRITICAL **: 22:09:38.906: Error: There is no window named launcher
getWindow@resource:///com/github/Aylur/ags/app.js:133:27
toggleWindow@resource:///com/github/Aylur/ags/app.js:108:24
on_clicked@file:///home/alpha/.config/ags/widgets/bar/Bar.js:21:9
Button/<@resource:///com/github/Aylur/ags/widgets/button.js:28:44
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

Maybe the Negative content width -35 (allocation 1, extents 18x18) while allocating gadget (node box, owner Ags_Box) warning might be related to the issue?

Anything I can do to debug the issue? I'm lost.

kotontrion commented 7 months ago

The relevant issues here are the errors about focusable, stack.items and monitorFile.

Here is how to fix them:


//focusable
Widget.Window ({
  focusable: true, //deprecated
  keymode: "on-demand", // works
})

//stack
Widget.Stack({
  items: [ // deprecated
    ["name1", widget1],
    ["name2", widget3]
  ], 
  children : { // works
    "name1": widget1,
    "name2": widget3,
  }
})

//monitor
Utils.monitorFile( path, callback, 'directory', ) //deprecated
Utils.monitorFile( path, callback) // works
Zerodya commented 7 months ago

Thank you, this was indeed the reason. No idea why I skipped over those errors.