Override the "unmanaged" signal Javascript extension

In the code below I am actually able to log when the window is closed, but I cannot disable the default closing mechanism. Does anybody know how to do that?

const { Gio, GLib, Meta, Shell } = imports.gi;
const Main = imports.ui.main;

function init() {

function enable() {
  global.display.connect("window-created", (display, metaWindow) => {
    let app = metaWindow.get_wm_class();
    if (app == "Spotify") {
      let appId;

      function onClose(){

        // i need to disable the default closing behavior

        console.log("[minimize-spotify] Spotify closed");
        console.log("[minimize-spotify] " + metaWindow);
        console.log("[minimize-spotify] appId: " + appId);

        return true;

      appId = metaWindow.connect("unmanaged", onClose.bind(this));



function disable() {

In the gnome-shell issue you opened, you explained that what you want to achieve is interject a close request, and instead force the window to minimize.

That’s not possible.

If the window is providing its own decorations (on wayland, or with custom decorations like headerbars), then the request is handled by the client itself.

If the window is decorated by the window manager (only in the xorg session), then the request is handled by a separate “frame-client” process.

In either case, there is no way of forcing a client to stay running. If a window is gone (i.e. destroyed by the client), it is gone.

Oh i get it. Would you have any suggestion on how to achieve the same result? Maybe listening for keyboard shortcut (Meta + w) and forwarding the request only if the window class is not of the one specified… Thanks very much for your reply anyways!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.