What are the commands for the given keybindings?

I am coming from linux - How can I find which command is bound to a given keyboard shortcut in gnome? - Unix & Linux Stack Exchange

I want to know the dbus / cli commands associated with the following keybindings.

/org/gnome/desktop/wm/keybindings/maximize 
/org/gnome/desktop/wm/keybindings/unmaximize 
/org/gnome/desktop/wm/keybindings/toggle-maximized
/org/gnome/desktop/wm/keybindings/minimize
/org/gnome/desktop/wm/keybindings/toggle-fullscreen
/org/gnome/desktop/wm/keybindings/toggle-tiled-left
/org/gnome/desktop/wm/keybindings/toggle-tiled-right
/org/gnome/desktop/wm/keybindings/show-desktop

As I already answered to you when you asked the same on the gnome-shell-extensions mailing list: All those shortcuts are handled by internal mutter functions, not via D-Bus or CLI commands.

Thank you very much for directing me to this forum.

So, how can i solve the problem mentioned in

neither xdotool nor wmctrl is working when the window is tiled or snapped. You can test the first command on the github issue. You can also check with the scripts provided with the issue.

I also want to mention that mutter is not even installed on my machine? Does gnome shell use it as a library or something like that?

Mutter is the library that gnome-shell uses to implement the X (and wayland) window manager.

Xdotool and wmctrl are generally poor options if you need full control over the window manager, the best way to get full control over it (in GNOME) is to write a shell extension.

1 Like

Suppose I want to create a shell extension. The job of the extension will be:

  1. when i press a keyboard shortcut, it will get the classname of the active window. For example, nemo, alacritty etc.
  2. The it will list all the windows that share the same classname.
  3. Then it will move the windows in specific coordinates. It will also resize the windows.

Is it possible with gnome shell extensions? Please give me some guideline on how to do that.

You will have to read a tutorial like the extension guide to get a general idea of how to write extensions. In the extension you can call global.get_window_actors() to get a list of windows. Then you can do something like this to move and resize the windows:

const current = global.get_window_actors().find(win => win.has_focus());
for (const win of global.get_window_actors()) {
  if (win.meta_window.wm_class === current?.meta_window.wm_class) {
    if (win.meta_window.get_maximized() !== 0)
      win.meta_window.unmaximize(Meta.MaximizeFlags.BOTH);
    const x = 0, y = 0, w = 100, h = 100; // TODO - calculate the right size
    win.meta_window.move_resize_frame(true, x, y, w, h);
  }
}
1 Like

Thank you very much.

xdotool has few commands like getactivewindow, get_desktop, windowminimize, windowsize, windowmove, windowactivate etc.

It also has command like:

xdotool search --onlyvisible --desktop $WORKSPACE --classname $CLASS_NAME

which search windows of a given class.

So, if I make an extension that will have these functions, i will be able to call these functions from a bash script using busctl, dbus-send or gdbus etc.

Is that it or is there any better solution (without using dbus). The point is I want to call functions defined in gnome extension from a shell script.

Please check https://github.com/jordansissel/xdotool/issues/398#issuecomment-1228312383 for more context.

IMO it would be better to avoid shell scripts, and just write the necessary functionality in the extension as javascript. It is possible to do like that extension and expose anything from the shell as dbus functionality, but this a pretty roundabout way to do it. And also, it is not secure as anything with access to the session bus could abuse that to mess with the window manager.

1 Like

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