Take charge of your window manager with WMCTRL and Devil's Pie

From: linux.com  read times: 98


Provided by yangyi at 2007-12-22 21:16:54


There are literally dozens of window managers that you can use with your favorite desktop environment to get a beautiful and appealing desktop. If you want to fine-tune your window manager, here are two programs that can help you control everything from application window size to pinning an application to all workspaces to fixing a position for your application windows to resizing desktops. One, wmctrl, works with any window managers that adheres to the Extended Window Manager Hints (EWMH), while Devil's Pie is a window-matching utility, which means it can configure application windows based on defined rules.

wmctrl is a command-line utility that can be used to manipulate or control various aspects of application windows and the desktop environment. Fedora and Ubuntu users can use yum or apt-get respectively to install wmctrl on their machines, or you can grab the compressed tarball from the software's Web site. According to the site, wmctrl is known to work with IceWM, Blackbox, Metacity, Openbox, Kwin, Enlightenment, and several other window managers.

There isn't much documentation for wmctrl, but the detailed man page is enough to start you in the right direction. The command wmctrl -m will print out details about the desktop environment and the window manager. You can use the -l switch to get a list of all the active windows (applications) in space-separated columns. The first column is a hexadecimal number, which is unique for each window. The second is the desktop number, or the workspace -- 0 means the first workspace, 1 means the second, and so on. The machine name is listed in the third column, and the last column contains the window title:

wmctrl -l
0x03400175  0 localhost.localdomain XChat: linuxlala @ FreeNode (formerly OpenProjects.net) / #fedora (+tncrRL)
0x0240007e  0 localhost.localdomain Gmail - Inbox (33) - Mozilla Firefox
0x03c00035  0 localhost.localdomain wmctrl_devilspie_article (~/Desktop) - gedit
0x03e0001e  0 localhost.localdomain linuxlala@localhost:~

To manipulate any window, you need to know its title. The command, wmctrl -a gedit will make the Gedit window active. This is most useful when you have several windows open in various workspaces. But what happens if you are simultaneously working with several Gedit windows? You can easily retitle any window with the command wmctrl -r :SELECT: -T "cool feature". The :SELECT: option enables you to select the application window whose title you wish to change by clicking on it -- though not by using the Alt-Tab key combination. When you click on any window, its title immediately changes to the one specified. You can specify the current title of the window instead of using the :SELECT: option. For example, wmctrl -r XChat -T "IRC" would retitle my XChat window to IRC.

You can also resize windows with wmctrl using the -r and the -e switches. The -r switch specifies a window and the -e switch resizes a window already specified. wmctrl -r gedit -e 1,20,30,750,1200 would resize the Gedit application window. For this to work, the application window must not be in a maximized state. The -e swtich expects five values: gravity, X-position, Y-position, width, and height. The X and Y positions respectively describe the position of the window from the left and top of the screen. Gravity is used to specify the position of the window's frame and it can be any value from 1 to 9. Each value maps to a position on the screen. The values it can take are northwest (1), north (2), northeast (3), west (4), center (5), east (6), southwest (7), south (8), and southeast (9).

......

Please access the below link to view the full content.

Original link: http://www.linux.com/feature/122471