Set window size and position from the command line

Step 1: Install wmctrl utility

[volkov@hp440 ~]$ sudo dnf info wmctrl
Available Packages
Name         : wmctrl
Version      : 1.07
Release      : 33.fc37
Architecture : x86_64
Size         : 35 k
Source       : wmctrl-1.07-33.fc37.src.rpm
Repository   : fedora
Summary      : Command line tool to interact with an X Window Manager
URL          : http://sweb.cz/tripie/utils/wmctrl
License      : GPLv2+
Description  : The wmctrl program is a UNIX/Linux command line tool to interact with an
             : EWMH/NetWM compatible X Window Manager. The tool provides command line access
             : to almost all the features defined in the EWMH specification. It can be used,
             : for example, to obtain information about the window manager, to get a detailed
             : list of desktops and managed windows, to switch and resize desktops, to make
             : windows full-screen, always-above or sticky, and to activate, close, move,
             : resize, maximize and minimize them. The command line access to these window
             : management functions makes it easy to automate and execute them from any
             : application that is able to run a command in response to an event.

[volkov@hp440 ~]$
[volkov@hp440 ~]$ sudo dnf install wmctrl

Step 2: Find the desired window identity and set window position and size (-e 0,x,y,width,height)

[volkov@hp440 ~]$ wmctrl -l
0x00c00003  0 hp440 Google Maps - Google Chrome
[volkov@hp440 ~]$
[volkov@hp440 ~]$ wmctrl -i -r 0x00c00003 -e 0,-1,-1,1280,720
[volkov@hp440 ~]$

(the value of -1 is interpreted to mean that the current geometry value should not be modified)

Unfortunately, wmctrl is for X window management whereas GNOME/GTK and some other apps are native Wayland not using X. Only legacy apps using Xwayland will show up in wmctrl


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *