Monday, January 04, 2010

Opening applications at selected locations under X

Since the beginning of X you have been able to open applications at selected positions by passing the following parameter:

-geometry [<width>x<height>][(+<left>|-<right>)(+<top>|-<bottom>)]

Under gnome you can pass a slightly modified parameter:

--geometry [<width>x<height>][(+<left>|-<right>)(+<top>|-<bottom>)]

Note the double-dash for the gnome version. If you use a left or top argument, your window will be placed relative to left or top of the screen. Likewise, -right or -bottom are relative to right and bottom of the screen.

If you use a location of 0, you window will be placed along the edge of the screen. An example:

gnome-terminal --geometry -0+0

open gnome-terminal top right of screen

gnome-terminal --geometry +0-50

Open terminal on left of the screen, 50 pixels from bottom of screen.

gnome-terminal --geometry 50x50

Open a terminal that is 50 characters wide and 50 characters tall.

gnome-terminal --geometry 50x50-0-0

Open a terminal that is 50 characters wide and 50 characters tall and on the right/bottom of the screen.

There is also a command that you can use to determine the current geometry of a window. You must run this command from a terminal because it prints its output to stdout:

xwininfo | grep -- -geometry

Click on the window you are interested in and you will get a geometry line that describes the current dimensions and location. You can use this to open a window that is the same width and height, or in the same location in the future.

Once you've got your geometry all worked out, just edit you gnome menu (right click on applications) and change the command that is run when your application is launched. If you are not sure how to pass a parameter, just add a space after the command name and then put the full parameter after that.

No comments: