0

Problem

I'm on a default Ubuntu 22.04 desktop. I repeatedly have to move windows around on my desktop and I would like to do that using a script.

wmctrl

This seems like it was a solution in the past and it still works with some apps (e.g.: Signal desktop), but for example it does not recognize the terminal window (anymore?).

dbus

I've read a couple of threads where people used dbus to do some automation. And it makes sense to me that this could be the solution. I just have trouble finding the information or even finding out if this is at all possible.

Using d-feet I see a bunch of stuff in the system and session bus. And I even managed to get some info (org.gnome.Terminal has a bunch of methods). But now I'm already at my first blocker: What kind of parameter do they expect?

/org/gnome/Terminal/window/1

Activate (String action_name, Array of [Variant] parameter, Dict of {String, Variant} platform_data) ↦ ()

If I want to activate a window, what else could it expect other than the window ID?

Other apps

Signal offers some methods but they're all about notifications. Thunderbird and pycharm do not offer anything.

Summary

I think if I want to manage windows (move, maximize, minimize, activate), I should be talking to a desktop service? Not the apps themselves? How do I find more info on what to do? Is there documentation on what parameters those methods expect? I'm totally fine if you only have pointers to additional documentation since this seems kind of a new area and people don't have that one super command at hand that solves all issues.

1 Answer 1

0

To manipulate windows in Gnome Shell from the command line, you can install the extension Window Calls by domandoman. It exposes a dbus interface that can return list of windows, move, resize, close them etc. The extension Window Calls Extended by hseliger expands on this in that it allows to obtain information on the window under focus.

6
  • Ok, thanks. The problem with this library/extension is the first command in the README already doesn't work: Error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/gnome/Shell/Extensions/Windows”. I tried to find similar methods by using busctl tree --user org.gnome.Shell.Extensions, but haven't found anything yet.
    – hofrob
    Nov 20, 2022 at 12:51
  • I played with this extension before and had no issues. Sure the extension is properly installed? Perhaps try logging out and in again.
    – vanadium
    Nov 20, 2022 at 12:52
  • Oh, I get it now. I thought those commands should work even without the extension. I will try to use this as an example to figure this out. Thanks!
    – hofrob
    Nov 20, 2022 at 12:59
  • These extensions expose custom dbus interfaces, so yes, they must be installed. In recent gnome shell versions, the standard gnome shell dbus interfaces are not anymore accessible from the terminal.
    – vanadium
    Nov 20, 2022 at 13:01
  • Thanks a lot! It works now (after fixing issues with how gnome extensions are run/installed). I can write scripts to handle all my windows exactly as I need it.
    – hofrob
    Nov 21, 2022 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.