You are not logged in.

#1 2014-11-16 11:10:42

dxxvi
Member
Registered: 2011-07-23
Posts: 122

[Solved] How to resize and position windows from command line?

I'd like to resize and position windows from the command line. I found the wmctrl application which allows me to do that but it doesn't allow me to make a window larger than the screen size while I can manually do that (drag the window so that its top left corner close to the bottom right corner of the screen, then drap the top left corner of the window to the top left corner of the screen, if I do it a few times, I can have a window of as large as 6000px by 4000px). Is there anyway to make a window quite large?

Thanks.

Last edited by dxxvi (2014-11-17 03:51:50)

Offline

#2 2014-11-16 12:36:28

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,202
Website

Re: [Solved] How to resize and position windows from command line?

Does wmctrl give an error message when you try to make the window larger than the screen?  What wmctrl command(s) are you using?  Wmctrl would have been my first suggestion.  Devilspie is another option.

Can I ask why you'd want to make a window so big?  Is this for a specific program that you could instead send a feature request upstream for a 'zoom' option?

EDIT: If you need a really simple tool to do just this (with no error checking whatsoever), the following code will work even with non-EWMH window managers.  Just pass the window ID in hex and four values for X Y Width and Height.

// compile: gcc -o moveresize moveresize.c -lX11

#include <stdlib.h>
#include <X11/Xlib.h>

int main(int argc, const char **argv) {
	if (argc < 6) return 1;
	Display *dpy = XOpenDisplay(0x0);
	XMoveResizeWindow(dpy, strtoul(argv[1], NULL, 0), atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]));
	XFlush(dpy);
	XCloseDisplay(dpy);
	return 0;
}

Last edited by Trilby (2014-11-16 12:56:49)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-11-16 19:34:47

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Re: [Solved] How to resize and position windows from command line?

Trilby wrote:

Does wmctrl give an error message when you try to make the window larger than the screen?  What wmctrl command(s) are you using?  Wmctrl would have been my first suggestion.  Devilspie is another option.

No, wmctrl doesn't give any error. I used

wmctrl -r "Google Maps - Mozilla Firefox (Private Browsing)" -e 5,1910,1050,3000,2000

Your program and wmctrl just maximize the window when I specify a window bigger than the screen.

Trilby wrote:

Can I ask why you'd want to make a window so big?

I want to copy the Google map to an image to view on my phone (I know Google Maps has an offline feature but that's not enough for me). Sorry Google for doing this. Google draws its maps on a canvas in the browser which has the size of the browser window. I copy the data on that canvas and put it in a file. The bigger my browser window is, the less number of times I have to put those images together.

Offline

#4 2014-11-16 19:50:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,202
Website

Re: [Solved] How to resize and position windows from command line?

dxxvi wrote:

Your program and wmctrl just maximize the window when I specify a window bigger than the screen.

I don't know the internals of wmctrl, but my code is pretty simple.  If the window is maximized instead of set to that size, then your window manager is overriding the settings.  Unless there is a way to prevent the WM from doing this, no tool would be able to help - but you could just use a different X session with a simpler window manager (or no WM at all).

I tested my code under openbox and it works fine with that.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2014-11-16 21:13:39

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Re: [Solved] How to resize and position windows from command line?

Trilby wrote:

If the window is maximized instead of set to that size, then your window manager is overriding the settings.

Ah, I see. Thanks for that. I'll try openbox.

Offline

Board footer

Powered by FluxBB